var context = new Vala.CodeContext ();
this.package_cache = this.loadPackages(Path.get_dirname (context.get_vapi_path("glib-2.0")));
+ this.package_cache.add_all(
+ this.loadPackages(Path.get_dirname (context.get_vapi_path("gee-1.0")))
+ );
//this.load();
// various loader methods..
//this.map = [];
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,
var ret = new List<SourceCompletionItem>();
// completion rules??
+ // make sure data is loaded
+ Gir.factory("Gtk");
+
// Roo......
// this. (based on the node type)
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 : " + str));
+ 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;
}
+
- return ret;
-
- // got at least one ".".
+ // got at least one ".".
var parts = complete_string.split(".");
var curtype = "";
var cur_instance = false;
print("node is empty - no return\n");
return ret; // no idea..
}
- curtype = '*' + node.fqn();
+ curtype = "*" + node.fqn();
cur_instance = true;
+ } else {
+ if (Gir.cache.get(parts[0]) == null) {
+ return ret;
+ }
+ curtype = parts[0];
}
// all Gtk.... etc.. types...
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] != '*') {
if (!is_last) {
- if (curtype[0] == '*' && parts[i] = "el") {
+ 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) {
}
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) {
+ 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..
if (!cur_instance) {
print("matching instance");
// it's a static reference..
- var citer = this.classes.map_iterator();
+ var citer = cls.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) {
+
+ if (parts[i].length > 0 && scls.index_of(parts[i],0) != 0) {
continue;
}
// got a starting match..
ret.append(new SourceCompletionItem (
- scls,
- scls,
+ 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();