[Sciviews-commits] r182 - komodo/SciViews-K komodo/SciViews-K/pylib pkg/svMisc pkg/svMisc/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat Aug 29 12:42:24 CEST 2009


Author: phgrosjean
Date: 2009-08-29 12:42:13 +0200 (Sat, 29 Aug 2009)
New Revision: 182

Modified:
   komodo/SciViews-K/pylib/lang_r.py
   komodo/SciViews-K/sciviewsk-0.8.1-ko.xpi
   pkg/svMisc/NEWS
   pkg/svMisc/R/Args.R
   pkg/svMisc/R/CallTip.R
   pkg/svMisc/R/Complete.R
Log:
Better handling of calltips

Modified: komodo/SciViews-K/pylib/lang_r.py
===================================================================
--- komodo/SciViews-K/pylib/lang_r.py	2009-08-29 09:45:50 UTC (rev 181)
+++ komodo/SciViews-K/pylib/lang_r.py	2009-08-29 10:42:13 UTC (rev 182)
@@ -2694,7 +2694,7 @@
 
     # Used by ProgLangTriggerIntelMixin.preceding_trg_from_pos()
     trg_chars = tuple('$@[( ')
-    calltip_trg_chars = tuple('(')
+    calltip_trg_chars = tuple('(,')
 
     ##
     # Implicit triggering event, i.e. when typing in the editor.
@@ -2751,7 +2751,7 @@
                 print "triggered:: complete quoted variables"
             return Trigger(self.lang, TRG_FORM_CPLN, "quotevariables",
                            pos, implicit)            
-        elif char == '(':
+        elif char == '(' or char == ',':
             # Function calltip trigger.
             if DEBUG:
                 print "triggered:: function calltip"
@@ -2820,7 +2820,7 @@
         elif char == '[':
             return Trigger(self.lang, TRG_FORM_CPLN, "quotevariables",
                             pos, implicit=False)
-        elif char == '(':
+        elif char == '(' or char == ',':
             # Function calltip trigger.
             if DEBUG:
                 print "triggered:: function calltip"
@@ -2889,7 +2889,7 @@
 
         if trg.id == (self.lang, TRG_FORM_CALLTIP, "call-signature"):
             # Get function calltip.
-            working_text = buf.accessor.text_range(max(0, pos-500), pos-1)
+            working_text = buf.accessor.text_range(max(0, pos-500), pos)
             complete_zone = buf.accessor.text_range(pos, pos)
             calltip = R.calltip(working_text)
             # This is done asynchronously by the R.calltip() function

Modified: komodo/SciViews-K/sciviewsk-0.8.1-ko.xpi
===================================================================
(Binary files differ)

Modified: pkg/svMisc/NEWS
===================================================================
--- pkg/svMisc/NEWS	2009-08-29 09:45:50 UTC (rev 181)
+++ pkg/svMisc/NEWS	2009-08-29 10:42:13 UTC (rev 182)
@@ -4,7 +4,13 @@
 
 * Complete() now sorts items alphabetically and does not return completions
   as factor type in the data frame any more.
+
+* CallTip() does a better work to find current function, i.e., not only after
+  the opening parentheses '('.
   
+* Args() now do no place a space anymore between the name of a function and its
+  arguments
+  
 
 == Changes in svMisc 0.9-52
 

Modified: pkg/svMisc/R/Args.R
===================================================================
--- pkg/svMisc/R/Args.R	2009-08-29 09:45:50 UTC (rev 181)
+++ pkg/svMisc/R/Args.R	2009-08-29 10:42:13 UTC (rev 182)
@@ -12,7 +12,7 @@
 		res <- sub("^function *[(]", "", res)
 		res <- sub(" *[)] *$", "", res)
 	} else {
-		res <- sub("^function", name, res)
+		res <- sub("^function *", name, res)
 		res <- sub(" *$", "", res)
 	}
 	return(res)

Modified: pkg/svMisc/R/CallTip.R
===================================================================
--- pkg/svMisc/R/CallTip.R	2009-08-29 09:45:50 UTC (rev 181)
+++ pkg/svMisc/R/CallTip.R	2009-08-29 10:42:13 UTC (rev 182)
@@ -1,12 +1,17 @@
 "CallTip" <-
 function (code, only.args = FALSE, location = FALSE)
 {
+	# This is the old treatment!
 	# Get a call tip, given a part of the code
 	# Extract the last variable name, given it is either at the end,
 	# or terminated by '('
-	code <- sub(" *\\($", "", code[1])
-	pos <- regexpr("[a-zA-Z0-9_\\.]+$", code)
-	code <- substring(code, pos)
+	#code <- sub(" *\\($", "", code[1])
+	#pos <- regexpr("[a-zA-Z0-9_\\.]+$", code)
+	#code <- substring(code, pos)
+	# Now, we use a more exhaustive search, using complete
+	code <- attr(Complete(code, types = NA), "fguess")
+	if (is.null(code) || !length(code) || code == "")
+		return("")
 
 	# Get the corresponding Call Tip
 	ctip <- "" # Default value, in case the function does not exist

Modified: pkg/svMisc/R/Complete.R
===================================================================
--- pkg/svMisc/R/Complete.R	2009-08-29 09:45:50 UTC (rev 181)
+++ pkg/svMisc/R/Complete.R	2009-08-29 10:42:13 UTC (rev 182)
@@ -6,7 +6,7 @@
 	finalize <- function (completions) {
 		# Sort completion items alphabetically
 		completions <- sort(completions)
-		if (add.types) {
+		if (isTRUE(add.types)) {
 			tl <- numeric(length(completions))
 			tl[grep(" = $", completions)] <- 4L
 			tl[grep("::$", completions)] <- 3L
@@ -28,8 +28,8 @@
 		attr(ret, "funargs") <- funargs
 		attr(ret, "isFirstArg") <- isFirstArg
 
-		if (print) {
-			if (add.types)
+		if (isTRUE(print)) {
+			if (isTRUE(add.types))
 				completions <- paste(completions, tl, sep = type.sep)
 			cat(triggerPos, completions, sep = sep)
 			if (sep != "\n") cat("\n")
@@ -45,7 +45,7 @@
 			scintilla = .scintilla.completion.types,
 			.default.completion.types)
 	}
-	add.types <- !is.na(types[1L])
+	if (is.na(types[1L])) add.types <- FALSE else add.types <- TRUE
 
 	# Default values for completion context
 	token <- ""
@@ -132,7 +132,7 @@
 	if (length(i) > 0)
 		completions <- completions[-i]
 
-	if (addition && triggerPos > 0L)
+	if (isTRUE(addition) && triggerPos > 0L)
 		completions <- substring(completions, triggerPos + 1)
 
 	if (dblBrackets) {



More information about the Sciviews-commits mailing list