+using Gtk;
+
namespace Palete {
//}
// use introspection to get lists..
- var es = ename.split(".");
+ var es = ename.split(".");
var gir = Gir.factory(es[0]);
var cls = gir.classes.get(es[1]);
var ret = new Gee.ArrayList<string>();
//this.package_cache = new Gee.ArrayList<string>();
-
+
+ if (!GLib.FileUtils.test(dirname, FileTest.IS_DIR)) {
+ print("opps package directory %s does not exist", dirname);
+ return ret;
+ }
var dir = File.new_for_path(dirname);
+
+
try {
var file_enum = dir.enumerate_children(
GLib.FileAttribute.STANDARD_DISPLAY_NAME,
public override List<SourceCompletionItem> suggestComplete(
JsRender.JsRender file,
- JsRender.Node node,
+ JsRender.Node? node,
string proptype,
string key,
string complete_string
) {
-
- return new List<SourceCompletionItem>();
+
+ var ret = new List<SourceCompletionItem>();
+ // completion rules??
+
+ // make sure data is loaded
+ Gir.factory("Gtk");
+
+ // 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 vala keywords... / _this .. / look for var string = .. in the code..
+
+ var max = (int)Vala.TokenType.YIELD +1;
+ for (var i =0; i < max;i++) {
+ var m = (Vala.TokenType)i;
+ var s = m.to_string();
+ var ss = s.slice(1,-1);
+ if (s[0] == '`' && GLib.Regex.match_simple("^[a-z]+$", ss) &&
+ complete_string != ss && ss.index_of(complete_string,0) == 0 ) {
+ ret.append(new SourceCompletionItem (ss, ss, null, "vala : " + ss));
+ }
+ }
+ var miter = Gir.cache.map_iterator();
+ while (miter.next()) {
+ var ss = miter.get_key();
+
+ if (complete_string != ss && ss.index_of(complete_string,0) == 0 ) {
+ ret.append(new SourceCompletionItem (ss, ss, null, "vala namespace : " + ss));
+ }
+ }
+
+
+ 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"));
+ }
+ // basic types..
+
+ 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;
+ } else {
+ if (Gir.cache.get(parts[0]) == null) {
+ return ret;
+ }
+ curtype = parts[0];
+ }
+ // all Gtk.... etc.. types...
+
+
+ //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 = Gir.factoryFqn(curtype);
+ if (cls == null && curtype[0] != '*') {
+ print("could not get class of curtype %s\n", curtype);
+ return ret;
+ }
+
+ if (!is_last) {
+
+ if (curtype[0] == '*' && parts[i] == "el") {
+ curtype = curtype.substring(1);
+ prevbits += parts[i] + ".";
+ continue;
+ }
+
+ // only exact matches from here on...
+ if (cur_instance) {
+ if (cls == null) {
+ return ret;
+ }
+ 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...
+ }
+ var look = prevbits + parts[i];
+ var scls = Gir.factoryFqn(look);
+ if (scls == null) {
+ return ret;
+ }
+ curtype = look;
+ 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 = cls.classes.map_iterator();
+ while (citer.next()) {
+ var scls = citer.get_key();
+
+ if (parts[i].length > 0 && scls.index_of(parts[i],0) != 0) {
+ continue;
+ }
+ // got a starting match..
+ ret.append(new SourceCompletionItem (
+ prevbits + scls,
+ prevbits + scls,
+ null,
+ scls));
+ }
+ // methods....
+ citer = cls.methods.map_iterator();
+ while (citer.next()) {
+ var scls = citer.get_key();
+
+ if (parts[i].length > 0 && scls.index_of(parts[i],0) != 0) {
+ continue;
+ }
+ // got a starting match..
+ ret.append(new SourceCompletionItem (
+ prevbits + scls + citer.get_value().sig ,
+ prevbits + scls,
+ null,
+ scls));
+ }
+
+ // enums....
+ citer = cls.consts.map_iterator();
+ while (citer.next()) {
+ var scls = citer.get_key();
+
+ if (parts[i].length > 0 && scls.index_of(parts[i],0) != 0) {
+ continue;
+ }
+ // got a starting match..
+ ret.append(new SourceCompletionItem (
+ prevbits + scls + citer.get_value().sig ,
+ prevbits + scls,
+ null,
+ scls));
+ }
+
+
+ return ret;
+ }
+ print("matching property");
+ if (cls == null) {
+ return ret;
+ }
+
+
+ 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;
}
-
}
}