[rkward-cvs] SF.net SVN: rkward:[3467] trunk/rkward

tfry at users.sourceforge.net tfry at users.sourceforge.net
Mon Mar 7 10:38:01 UTC 2011


Revision: 3467
          http://rkward.svn.sourceforge.net/rkward/?rev=3467&view=rev
Author:   tfry
Date:     2011-03-07 10:38:01 +0000 (Mon, 07 Mar 2011)

Log Message:
-----------
Rework object name completion, and object lookup functions.
This is more correct with respect to quotes. Also, it is a pre-requisite for handling S4 slots in completions.

Modified Paths:
--------------
    trunk/rkward/ChangeLog
    trunk/rkward/rkward/core/rcontainerobject.cpp
    trunk/rkward/rkward/core/rcontainerobject.h
    trunk/rkward/rkward/core/robject.cpp
    trunk/rkward/rkward/core/robject.h
    trunk/rkward/rkward/core/robjectlist.cpp
    trunk/rkward/rkward/core/robjectlist.h
    trunk/rkward/rkward/misc/rkcommonfunctions.cpp
    trunk/rkward/rkward/rkconsole.cpp

Modified: trunk/rkward/ChangeLog
===================================================================
--- trunk/rkward/ChangeLog	2011-03-03 17:09:42 UTC (rev 3466)
+++ trunk/rkward/ChangeLog	2011-03-07 10:38:01 UTC (rev 3467)
@@ -1,3 +1,4 @@
+- More correct handling of quotes in object name completion
 - Support plot history for ggplot2 plots
 - Be less pro-active about fetching structure information on R objects in the workspace		TODO: verify that this fixes our issues with rXML
 - Allow to browse arbitrarily deeply nested environments in the object browser

Modified: trunk/rkward/rkward/core/rcontainerobject.cpp
===================================================================
--- trunk/rkward/rkward/core/rcontainerobject.cpp	2011-03-03 17:09:42 UTC (rev 3466)
+++ trunk/rkward/rkward/core/rcontainerobject.cpp	2011-03-07 10:38:01 UTC (rev 3467)
@@ -269,53 +269,33 @@
 	return childmap.indexOf (child);
 }
 
-RObject *RContainerObject::findObject (const QString &name, bool is_canonified) const {
+RObject *RContainerObject::findObjects (const QStringList &path, RObjectSearchMap *matches, const QString &op) {
 	RK_TRACE (OBJECTS);
 
-	QString canonified = name;
-	if (!is_canonified) canonified = canonifyName (name);
-
-	// TODO: there could be objects with "$" in their names!
-	QString current_level = canonified.section (QChar ('$'), 0, 0);
-	QString remainder = canonified.section (QChar ('$'), 1);
-
-	RObject* found = findChildByName (current_level);
-	if (!found) return 0;
-
-	if (remainder.isEmpty ()) return found;
-
-	return (found->findObject (remainder, true));
-}
-
-void RContainerObject::findObjectsMatching (const QString &partial_name, RObjectSearchMap *current_list, bool name_is_canonified) {
-	RK_TRACE (OBJECTS);
-	RK_ASSERT (current_list);
-
 	fetchMoreIfNeeded ();
 
-	QString canonified = partial_name;
-	if (!name_is_canonified) canonified = canonifyName (partial_name);
+	if (op != "$") return RObject::findObjects (path, matches, op);
 
-	// TODO: there could be objects with "$" in their names!
-	QString current_level = canonified.section (QChar ('$'), 0, 0);
-	QString remainder = canonified.section (QChar ('$'), 1);
+	if (path.length () > 1) {
+		RObject* found = findChildByName (path.value (0));
+		if (found) return found->findObjects (path.mid (2), matches, path.value (1));
+	} else {
+		if (!matches) return findChildByName (path.value (0));
 
-	if (remainder.isEmpty () && !canonified.endsWith (QChar ('$'))) {
+		QString partial = path.value (0);
 		for (int i = 0; i < childmap.size (); ++i) {
 			RObject* child = childmap[i];
-			if (child->getShortName ().startsWith (current_level)) {
+			if (partial.isEmpty () || child->getShortName ().startsWith (partial)) {
 				QString base_name = child->getBaseName ();
-				if (current_list->contains (base_name) || irregularShortName (base_name)) {
-					current_list->insert (child->getFullName (), child);
+				if (matches->contains (base_name) || irregularShortName (base_name)) {
+					matches->insert (child->getFullName (), child);
 				} else {
-					current_list->insert (base_name, child);
+					matches->insert (base_name, child);
 				}
 			}
 		}
-	} else {
-		RObject* found = findChildByName (current_level);
-		if (found) found->findObjectsMatching (remainder, current_list, true);
 	}
+	return 0;
 }
 
 RObject *RContainerObject::createPendingChild (const QString &name, int position, bool container, bool data_frame) {

Modified: trunk/rkward/rkward/core/rcontainerobject.h
===================================================================
--- trunk/rkward/rkward/core/rcontainerobject.h	2011-03-03 17:09:42 UTC (rev 3466)
+++ trunk/rkward/rkward/core/rcontainerobject.h	2011-03-07 10:38:01 UTC (rev 3467)
@@ -2,7 +2,7 @@
                           rcontainerobject  -  description
                              -------------------
     begin                : Thu Aug 19 2004
-    copyright            : (C) 2004, 2006, 2007, 2010 by Thomas Friedrichsmeier
+    copyright            : (C) 2004, 2006, 2007, 2010, 2011 by Thomas Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -61,12 +61,6 @@
 	/** given child_name, constructs a name which is as close as possible to the orginial but valid (i.e. not already in use, not contaning illegal characters */
 	QString validizeName (const QString &child_name, bool unique=true) const;
 
-	/** reimplemented from RObject to actually search for the object */
-	virtual RObject *findObject (const QString &name, bool is_canonified=false) const;
-
-	/** reimplemented from RObject to actually search for matching objects */
-	void findObjectsMatching (const QString &partial_name, RObjectSearchMap *current_list, bool name_is_canonified=false);
-
 	void moveChild (RObject* child, int from_index, int to_index);
 
 	/** reimplemented from RObject to do nothing at all, including not raising an assert. This is because container objects do not have any edit data, themselves, but may be opened for editing, e.g. as a data.frame */
@@ -79,6 +73,9 @@
 	/** usually, we do not update the structure of the row.names() from R, as it is always the same. However, we may need to adjust the length, and this hack does that. */
 	void updateRowNamesObject ();
 protected:
+	/** reimplemented from RObject to actually search for matching objects among the children */
+	RObject *findObjects (const QStringList &path, RObjectSearchMap *matches, const QString &op);
+
 	void updateChildren (RData *new_children);
 	RObjectMap childmap;
 	RKRowNames *rownames_object;

Modified: trunk/rkward/rkward/core/robject.cpp
===================================================================
--- trunk/rkward/rkward/core/robject.cpp	2011-03-03 17:09:42 UTC (rev 3466)
+++ trunk/rkward/rkward/core/robject.cpp	2011-03-07 10:38:01 UTC (rev 3467)
@@ -75,16 +75,13 @@
 	return getMetaProperty ("label");
 }
 
-RObject *RObject::findObject (const QString &, bool) const {
+RObject* RObject::findObjects (const QStringList &, RObjectSearchMap *, const QString &) {
 	RK_TRACE (OBJECTS);
+	// not a container
+	// TODO: handle '@'
 	return 0;
 }
 
-void RObject::findObjectsMatching (const QString &, RObjectSearchMap *, bool) {
-	RK_TRACE (OBJECTS);
-	return;
-}
-
 QString RObject::getMetaProperty (const QString &id) const {
 	RK_TRACE (OBJECTS);
 	if (meta_map) return (meta_map->value (id));
@@ -496,12 +493,76 @@
 	return (RKRSharedFunctionality::quote (string));
 }
 
-// static
-QString RObject::canonifyName (const QString &from) {
+//static 
+QStringList RObject::parseObjectPath (const QString &path) {
 	RK_TRACE (OBJECTS);
 
-	QString copy = from;
-	return (copy.replace ("[\"", "$").replace ('[', "").replace ("\"]", "").replace (']', ""));
+	QStringList ret;
+	QString fragment;
+
+	int end = path.length ();
+	QChar quote_char;
+	bool escaped = false;
+	bool seek_bracket_end = false;
+	for (int i = 0; i < end; ++i) {
+		QChar c = path.at (i);
+		if (quote_char.isNull ()) {
+			if (c == '\'' || c == '\"' || c == '`') {
+				quote_char = c;
+			} else {
+				if (!seek_bracket_end) {
+					if (c == '$') {
+						ret.append (fragment);
+						ret.append ("$");
+						fragment.clear ();
+					} else if (c == '[') {
+						ret.append (fragment);
+						ret.append ("$");
+						fragment.clear ();
+						if ((i+1 < end) && (path.at (i+1) == '[')) ++i;
+						seek_bracket_end = true;
+					} else if (c == ':') {
+						ret.append (fragment);
+						ret.append ("::");
+						fragment.clear ();
+						if ((i+1 < end) && (path.at (i+1) == ':')) ++i;
+					} else if (c == '@') {
+						ret.append (fragment);
+						ret.append ("@");
+						fragment.clear ();
+					} else {
+						fragment.append (c);
+					}
+				} else {
+					if (c == ']') {
+						if ((i+1 < end) && (path.at (i+1) == ']')) ++i;
+						seek_bracket_end = false;
+						continue;
+					} else {
+						fragment.append (c);
+					}
+				}
+			}
+		} else {	// inside a quote
+			if (c == '\\') escaped = !escaped;
+			else {
+				if (escaped) {
+					if (c == 't') fragment.append ('\t');
+					else if (c == 'n') fragment.append ('\n');
+					else fragment.append ('\\' + c);
+				} else {
+					if (c == quote_char) {
+						quote_char = QChar ();
+					} else {
+						fragment.append (c);
+					}
+				}
+			}
+		}
+	}
+	if (!fragment.isEmpty ()) ret.append (fragment);
+	RK_DO (qDebug ("parsed object path %s into %s", qPrintable (path), qPrintable (ret.join ("-"))), OBJECTS, DL_DEBUG);
+	return ret;
 }
 
 //virtual

Modified: trunk/rkward/rkward/core/robject.h
===================================================================
--- trunk/rkward/rkward/core/robject.h	2011-03-03 17:09:42 UTC (rev 3466)
+++ trunk/rkward/rkward/core/robject.h	2011-03-07 10:38:01 UTC (rev 3467)
@@ -160,16 +160,18 @@
 	static QString rQuote (const QString &string);
 /** Returns a pretty description of the object, and its most important properties. TODO should this be virtual or not? I suppose, it's a close call. For now, we do all work here with casts */
 	QString getObjectDescription () const;
-/** Returns a canonified name given a non-canoified name. Warning! This is not (necessarily) suitable for submission to
-R, only for internal lookup. For submission to R, always use RObject::getFullName (), as it will apply more complicated (and correct) rules depending on object type */
-	static QString canonifyName (const QString &from);
+/** Parses an object path (such as package::name[["a"]]$b at slot) into its components, returning them as a list (in this case 'package', '::' 'name', '$', 'a', '$', 'b', '@', 'slot'). */
+	static QStringList parseObjectPath (const QString &path);
 /** Tests whether the given name is "irregular", i.e. contains spaces, quotes, operators, or the like. @see RContainerObject::validizeName () */
 	static bool irregularShortName (const QString &name);
-/** Function for code completion: given the partial name, find all objects matching this partial name
+/** try to find the object as a child object of this object.
+ at param name of the object (relative to this object)
+ at returns a pointer to the object (if found) or 0 if not found */
+	RObject *findObject (const QString &name) { return findObjects (parseObjectPath (name), 0, "$"); };
+	/** Function for code completion: given the partial name, find all objects matching this partial name
 @param partial_name The partial name to look up
- at param current_list A pointer to a valid (but probably initially empty) RObjectMap. Matches will be added to this list
- at param name_is_canonified internal parameter. Set to true, if the name to match is already canonfied (else it will be canonified internally) */
-	virtual void findObjectsMatching (const QString &partial_name, RObjectSearchMap *current_list, bool name_is_canonified=false);
+ at param current_list A pointer to a valid (but probably initially empty) RObjectMap. Matches will be added to this list */
+	void findObjectsMatching (const QString &partial_name, RObjectSearchMap *current_list) { findObjects (parseObjectPath (partial_name), current_list, "$"); };
 
 /** Fetch more levels of object representation (if needed). Note: Data is fetched asynchronously. 
 @param levels levels to recurse (0 = only direct children). */
@@ -181,11 +183,6 @@
 		int to_index;
 	};
 
-/** try to find the object as a child object of this object. Default implementation always returns 0, as this is not a container
- at param name of the object (relative to this object)
- at param is_canonified the object name may usually have to be canonified. Since this function may be called recursively, canonification may already have occurred on a higher level. In this case the argument is set to true to avoid some duplicate work. When calling from outside always leave the default false.
- at returns a pointer to the object (if found) or 0 if not found */
-	virtual RObject *findObject (const QString &name, bool is_canonified=false) const;
 /** generates a (full) name for a child of this object with the given name. */
 	virtual QString makeChildName (const QString &short_child_name, bool misplaced=false) const;
 protected:
@@ -202,6 +199,9 @@
 	QVector<qint32> dimensions;
 	QStringList classnames;
 
+/** Worker function for findObject() and findObjectsMatching(). If matches != 0, look for partial matches, and store them in the map (findObjectsMatching()). Else look for exact matches and return the first match (findObject()). */
+	virtual RObject *findObjects (const QStringList &path, RObjectSearchMap *matches, const QString &op);
+
 	virtual QString makeChildBaseName (const QString &short_child_name) const;
 
 /** Update object to reflect the structure passed in the new_data argument. If the data is mismatching (i.e. can not be accommodated by this type of object) false is returned (calls canAccommodateStructure () internally). In this case you should delete the object, and create a new one.

Modified: trunk/rkward/rkward/core/robjectlist.cpp
===================================================================
--- trunk/rkward/rkward/core/robjectlist.cpp	2011-03-03 17:09:42 UTC (rev 3466)
+++ trunk/rkward/rkward/core/robjectlist.cpp	2011-03-07 10:38:01 UTC (rev 3467)
@@ -2,7 +2,7 @@
                           robjectlist  -  description
                              -------------------
     begin                : Wed Aug 18 2004
-    copyright            : (C) 2004, 2006, 2007, 2009, 2010 by Thomas Friedrichsmeier
+    copyright            : (C) 2004, 2006, 2007, 2009, 2010, 2011 by Thomas Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -209,63 +209,27 @@
 	return envobj;
 }
 
-RObject *RObjectList::findObject (const QString &name, bool is_canonified) const {
+RObject *RObjectList::findObjects (const QStringList &path, RObjectSearchMap *matches, const QString &op) {
 	RK_TRACE (OBJECTS);
+	RK_ASSERT (op == "$");
 
-	QString canonified = name;
-	if (!is_canonified) canonified = canonifyName (name);
-
-	// TODO: there could be objects with "::" in their names!
-	if (canonified.contains ("::")) {
-		QString env = canonified.section ("::", 0, 0);
-		QString remainder = canonified.section ("::", 1);
-
-		RObject *found = findChildByNamespace (env);
-		if (!found) return 0;
-
-		return (found->findObject (remainder, true));
-	} else if (canonified.startsWith (".GlobalEnv$")) {
-		return (getGlobalEnv ()->findObject (canonified.mid (11), true));
-	} else if (canonified == ".GlobalEnv") {
-		return (getGlobalEnv ());
-	}
-
-	// no "::"-qualification given, do normal search in all environments, return first match
-	for (int i = 0; i < childmap.size (); ++i) {
-		RObject *found = childmap[i]->findObject (canonified, true);
-		if (found) return found;
-	}
-	return 0;
-}
-
-void RObjectList::findObjectsMatching (const QString &partial_name, RObjectSearchMap *current_list, bool name_is_canonified) {
-	RK_TRACE (OBJECTS);
-	RK_ASSERT (current_list);
-
-	QString canonified = partial_name;
-	if (!name_is_canonified) canonified = canonifyName (partial_name);
-
-	// TODO: there could be objects with "::" in their names!
-	if (canonified.contains ("::")) {
-		QString env = canonified.section ("::", 0, 0);
-		QString remainder = canonified.section ("::", 1);
-
-		RObject *found = findChildByNamespace (env);
-		if (!found) return;
+	if (path.value (1) == "::") {
+		RObject *environment = findChildByNamespace (path[0]);
+		if (!environment) return 0;
 		
-		found->findObjectsMatching (remainder, current_list, true);
-		return;
-	} else if (canonified.startsWith (".GlobalEnv$")) {
-		getGlobalEnv ()->findObjectsMatching (canonified.mid (11), current_list, true);
-		return;
-	} else if (canonified == ".GlobalEnv") {
-		current_list->insert (canonified, getGlobalEnv());	// but do not return, there will be at least one further match in base
+		return environment->findObjects (path.mid (2), matches, "$");
+	} else if (path.value (0) == ".GlobalEnv") {
+		if (path.length () > 1) return getGlobalEnv ()->findObjects (path.mid (2), matches, "$");
+		else if (matches) matches->insert (path.value (0), getGlobalEnv ());	// no return, here: At least one more match will be found in base
+		else return getGlobalEnv ();
 	}
 
 	// no namespace given. Search all environments for matches
 	for (int i = 0; i < childmap.size (); ++i) {
-		childmap[i]->findObjectsMatching (canonified, current_list, true);
+		RObject *found = childmap[i]->findObjects (path, matches, "$");
+		if (found && !matches) return found;
 	}
+	return 0;
 }
 
 REnvironmentObject* RObjectList::findChildByNamespace (const QString &namespacename) const {

Modified: trunk/rkward/rkward/core/robjectlist.h
===================================================================
--- trunk/rkward/rkward/core/robjectlist.h	2011-03-03 17:09:42 UTC (rev 3466)
+++ trunk/rkward/rkward/core/robjectlist.h	2011-03-07 10:38:01 UTC (rev 3467)
@@ -2,7 +2,7 @@
                           robjectlist  -  description
                              -------------------
     begin                : Wed Aug 18 2004
-    copyright            : (C) 2004, 2006, 2007, 2009, 2010 by Thomas Friedrichsmeier
+    copyright            : (C) 2004, 2006, 2007, 2009, 2010, 2011 by Thomas Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -55,13 +55,7 @@
 	QString makeChildName (const QString &short_child_name, bool) const { return short_child_name; };
 	/** reimplemented from RContainerObject: do nothing. The object-list has no meta data. */
 	void writeMetaData (RCommandChain *) {};
-	
-	/** reimplemented from RContainerObject to search the environments in search order */
-	RObject *findObject (const QString &name, bool canonified=false) const;
 
-	/** reimplemented from RContainerObject to search the environments in search order */
-	void findObjectsMatching (const QString &partial_name, RObjectSearchMap *current_list, bool name_is_canonified=false);
-
 	KUrl getWorkspaceURL () const { return current_url; };
 
 	REnvironmentObject* findChildByNamespace (const QString &namespacename) const;
@@ -82,6 +76,9 @@
 /** emitted when the workspace Url has changed */
 	void workspaceUrlChanged (const KUrl& url);
 protected:
+/** reimplemented from RContainerObject to search the environments in search order */
+	RObject *findObjects (const QStringList &path, RObjectSearchMap *matches, const QString &op);
+
 /// reimplemented from RContainerObject to call "remove (objectname)" instead of "objectname <- NULL"
 	QString removeChildCommand (RObject *object) const;
 /// reimplemented from RContainerObject to call "remove (objectname)" instead of "objectname <- NULL"

Modified: trunk/rkward/rkward/misc/rkcommonfunctions.cpp
===================================================================
--- trunk/rkward/rkward/misc/rkcommonfunctions.cpp	2011-03-03 17:09:42 UTC (rev 3466)
+++ trunk/rkward/rkward/misc/rkcommonfunctions.cpp	2011-03-07 10:38:01 UTC (rev 3467)
@@ -2,7 +2,7 @@
                           rkcommonfunctions  -  description
                              -------------------
     begin                : Mon Oct 17 2005
-    copyright            : (C) 2005, 2006, 2007, 2009, 2010 by Thomas Friedrichsmeier
+    copyright            : (C) 2005, 2006, 2007, 2009, 2010, 2011 by Thomas Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -108,31 +108,43 @@
 		getCurrentSymbolOffset (context_line, cursor_pos, strict, &current_word_start, &current_word_end);
 	
 		// if both return the same position, we're on a non-word.
-		if (current_word_start == current_word_end) return (QString::null);
+		if (current_word_start == current_word_end) return (QString ());
 
 		return (context_line.mid (current_word_start, current_word_end - current_word_start));
 	}
 
 	void getCurrentSymbolOffset (const QString &context_line, int cursor_pos, bool strict, int *start, int *end) {
-		if (context_line.isEmpty ()) {
-			*start = 0;
-			*end = 0;
-			return;
-		}
+		*start = 0;
 
-		// step 1: find out word under cursor
-		// We want to match any valid R name, that is, everything composed of letters, 0-9, '.'s and '_'s..
-		QRegExp rx_no_word;
-		if (strict) {
-			rx_no_word = QRegExp ("[^A-Za-z0-9\\._]");
-		} else {
-			rx_no_word = QRegExp ("[^A-Za-z0-9\\._\\$\\:\\[\"\\]]");
+		int line_end = context_line.length () - 1;
+		*end = line_end + 1;
+		if (cursor_pos > line_end) cursor_pos = line_end;
+
+		QChar quote_char;
+		for (int i=0; i <= line_end; ++i) {
+			QChar c = context_line.at (i);
+			if (!quote_char.isNull ()) {
+				if (c == '\\') ++i;
+				if (c == quote_char) quote_char = QChar ();
+				continue;
+			} else {
+				if (c == '\'' || c == '\"' || c == '`') {
+					quote_char = c;
+					continue;
+				} else if (c.isLetterOrNumber () || c == '.' || c == '_') {
+					continue;
+				} else if (!strict) {
+					if (c == '$' || c == ':' || c == '[' || c == ']' || c == '@') continue;
+				}
+			}
+
+			// if we did not hit a continue, yet, that means we are on a potential symbol boundary
+			if (i < cursor_pos) *start = i+1;
+			else {
+				*end = i;
+				break;
+			}
 		}
-
-		// find out the next non-word stuff left and right of the current cursor position
-		*start = context_line.lastIndexOf (rx_no_word, cursor_pos-1) + 1;
-		*end = context_line.indexOf (rx_no_word, cursor_pos);
-		if (*end < 0) *end = context_line.length ();
 	}
 
 	QString getRKWardDataDir () {

Modified: trunk/rkward/rkward/rkconsole.cpp
===================================================================
--- trunk/rkward/rkward/rkconsole.cpp	2011-03-03 17:09:42 UTC (rev 3466)
+++ trunk/rkward/rkward/rkconsole.cpp	2011-03-07 10:38:01 UTC (rev 3467)
@@ -428,53 +428,20 @@
 	RKCommonFunctions::getCurrentSymbolOffset (current_line, cursor_pos, false, &word_start, &word_end);
 	QString current_symbol = current_line.mid (word_start, word_end - word_start);
 
-	// should we try a file name completion? Let's do some heuristics
-	bool do_file_completion = false;
-	int quote_start = current_line.lastIndexOf ('"', cursor_pos - 1);
-	if (quote_start < 0) quote_start = current_line.lastIndexOf ('\'', cursor_pos - 1);
+	// as a very simple heuristic: If the current symbol starts with a quote, we should probably attempt file name completion, instead of symbol name completion
+	if (current_symbol.startsWith ("\"") || current_symbol.startsWith ("\'") || current_symbol.startsWith ("`")) {
+		KUrlCompletion comp (KUrlCompletion::FileCompletion);
+		comp.setDir (QDir::currentPath ());
+		comp.makeCompletion (current_symbol.mid (1));
 
-	if (quote_start >= 0) {
-		// we found a quoting char at some earlier position on the line, we might need a filename completion
-		do_file_completion = true;
+		if (doTabCompletionHelper (current_line_num, current_line, word_start + 1, word_end, comp.allMatches ())) return;
+	} else if (!current_symbol.isEmpty ()) {
+		RObject::RObjectSearchMap map;
+		RObjectList::getObjectList ()->findObjectsMatching (current_symbol, &map);
 
-		// however, some characters around quotes signify it's probably not really filename string
-		char char_before_quote = ' ';
-		if (quote_start > 1) char_before_quote = current_line.at (quote_start - 1).toLatin1();
-		char char_after_quote = ' ';
-		if (quote_start <= (current_line.length() - 2)) char_after_quote = current_line.at (quote_start + 1).toLatin1();
-		// these signifiy it might be an object in a list somewhere, e.g. my.data$"varname"
-		if ((char_before_quote == '[') || (char_before_quote == '$') || (char_before_quote == ':')) do_file_completion = false;
-		// these indicate, the quote has likely ended rather that started
-		if ((char_after_quote == ',') || (char_after_quote == ')') || (char_after_quote == ' ') || (char_after_quote == ';')) do_file_completion = false;
-
-		if (do_file_completion) {
-			int quote_end = current_line.indexOf ('"', cursor_pos);
-			if (quote_end < 0) quote_end = current_line.indexOf ('\'', cursor_pos);
-			if (quote_end < 0) quote_end = current_line.length ();
-	
-			QString current_name = current_line.mid (quote_start + 1, quote_end - quote_start - 1);
-			KUrlCompletion comp (KUrlCompletion::FileCompletion);
-			comp.setDir (QDir::currentPath ());
-			comp.makeCompletion (current_name);
-	
-			if (doTabCompletionHelper (current_line_num, current_line, quote_start+1, quote_end, comp.allMatches ())) return;
-		}
+		if (doTabCompletionHelper (current_line_num, current_line, word_start, word_end, map.keys ())) return;
 	}
 
-	if (!do_file_completion) {
-		if (!current_symbol.isEmpty ()) {		// try object name completion first
-			RObject::RObjectSearchMap map;
-			RObject::RObjectSearchMap::const_iterator it;
-			RObjectList::getObjectList ()->findObjectsMatching (current_symbol, &map);
-	
-			QStringList entries;
-			for (it = map.constBegin (); it != map.constEnd (); ++it) {
-				entries.append (it.key ());
-			}
-			if (doTabCompletionHelper (current_line_num, current_line, word_start, word_end, entries)) return;
-		}
-	}
-
 	// no completion was possible
 	KApplication::kApplication ()->beep ();
 }


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the rkward-tracker mailing list