}
- // 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();
try {
- pa.load_from_file(BuilderApplication.configDirectory() + "/resources/roodata.json");
+ 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",BuilderApplication.configDirectory() + "/resources/roodata.json");
+ GLib.error("Could not load %s",f.get_uri());
}
var node = pa.get_root();
return true;
}
- public override Gee.ArrayList<CompletionProposal> suggestComplete(
- JsRender.JsRender file,
- JsRender.Node? node,
- JsRender.NodeProp? xxprop,
- string complete_string
- ) {
-
- var ret = new Gee.ArrayList<CompletionProposal>();
- // 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... ???tr,str,
- var sci = new CompletionProposal(str,str, "javascript: " + str);
- ret.add(sci);
-
- }
-
-
- }
- if (complete_string != "Roo" && "Roo".index_of(complete_string,0) == 0 ) {
- // should we ignore exact matches... ???
-
- var sci = new CompletionProposal("Roo - A Roo class","Roo", "Roo Library");
- ret.add(sci);
-
- }
- if (complete_string != "_this" && "_this".index_of(complete_string,0) == 0 ) {
- // should we ignore exact matches... ???
- var sci = new CompletionProposal("_this - Reference to the global pointer to the files main class instance",
- "_this", "Reference to the global pointer to the files main class instance");
- ret.add(sci);
-
- }
- 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..
- var sci = new CompletionProposal(scls,scls,scls);
- ret.add(sci);
- }
- 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?
-
-
- var sci = new CompletionProposal(prop.name + prop.sig + " : ("+ prop.propertyof + ")",
- prevbits + prop.name + "(",prop.doctxt);
- ret.add(sci);
-
- }
-
- // 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..
- var sci = new CompletionProposal(prop.name + prop.type + " : ("+ prop.propertyof + ")",
- prevbits + prop.name + "(",prop.doctxt);
- ret.add(sci);
-
- }
-
-
- return ret;
-
-
-
-
-
- }
-
-
-
-
-
-
- return ret;
- }
+
public override Gee.ArrayList<string> getChildList(string in_rval, bool with_prop)
}
foreach(var str in cls.can_drop_onto) {
-
ret.add(str);
}
+ if (this.top_classes.contains(rval)) {
+ ret.add("*top");
+ }
//GLib.debug("getDropList for %s return[] %s", rval, string.joinv(", ", ret));
this.dropCache.set(rval,ret);
return ret;