[Sciviews-commits] r412 - in komodo/SciViews-K-dev: . R components content
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Mon Dec 12 22:16:32 CET 2011
Author: prezez
Date: 2011-12-12 22:16:32 +0100 (Mon, 12 Dec 2011)
New Revision: 412
Added:
komodo/SciViews-K-dev/R/compat.R
komodo/SciViews-K-dev/R/quickParse.R
Modified:
komodo/SciViews-K-dev/R/captureAll.R
komodo/SciViews-K-dev/components/koRLinter.py
komodo/SciViews-K-dev/content/RHelpWindow.xul
komodo/SciViews-K-dev/install.rdf
komodo/SciViews-K-dev/sciviewsk-1.0.6dev-ko.xpi
Log:
SciViews-K-dev: linting fixed (correction in KoRLinter.py, added R/quickParse.R)
Modified: komodo/SciViews-K-dev/R/captureAll.R
===================================================================
--- komodo/SciViews-K-dev/R/captureAll.R 2011-12-11 19:39:50 UTC (rev 411)
+++ komodo/SciViews-K-dev/R/captureAll.R 2011-12-12 21:16:32 UTC (rev 412)
@@ -8,7 +8,7 @@
msg <- conditionMessage(x)
call <- conditionCall(x)
if (!is.null(call))
- paste(.gettextx("Error in "), deparse(call, control = NULL)[1L], ": ",
+ paste(.gettextx("Error in "), deparse(call, control = NULL)[1L], " : ",
msg, "\n", sep = "")
else paste(.gettextx("Error: "), msg, "\n", sep = "")
}
@@ -52,6 +52,14 @@
unlist(lapply(unlist(args), function(x) .Internal(ngettext(1, x, "", domain))))
}
+unsink <- function() {
+# DEBUG
+sink(type="m");sink(type="o")
+#browser()
+# END DEBUG
+}
+
+
# inspired by 'capture.output' and utils:::.try_silent
# Requires: R >= 2.13.0 [??]
`captureAll` <- function(expr, split = FALSE, file = NULL, markStdErr=FALSE,
@@ -62,7 +70,7 @@
last.warning <- list()
Traceback <- NULL
- NframeOffset <- sys.nframe() + 19L + 4L # frame of reference (used in traceback) +
+ NframeOffset <- sys.nframe() + 19L + 3L # frame of reference (used in traceback) +
# length of the call stack when a condition
# occurs
# Note: if 'expr' is a call not expression, 'NframeOffset' is lower by 2
@@ -110,12 +118,15 @@
# remove call (eval(expr, envir, enclos)) from the message
ncls <- length(calls)
- if(isTRUE(all.equal(calls[[NframeOffset + foffset]], e$call, check.attributes=FALSE)))
+ #browser()
+
+ if(identical(calls[[NframeOffset + foffset]], conditionCall(e)))
e$call <- NULL
cfrom <- ncls - 2L
cto <- NframeOffset + foffset
+
Traceback <<- if(cfrom < cto) list() else
calls[seq.int(cfrom, cto, by=-1L)]
@@ -143,16 +154,16 @@
resval <- res1$value
if(!missing(resval)) {
printfun <- as.name(if(isS4(resval)) "show" else "print")
- if(is.language(resval))
+ if(is.language(resval)) {
+ #browser()
+ #eval(substitute(printfun(resval)), envir)
+ #utils::str(resval)
eval(substitute(printfun(quote(resval))), envir)
- else
+ } else
eval(substitute(printfun(resval)), envir)
} else {
cat("\n")
}
-# DEBUG
-#sink(type="m");sink(type="o");browser()
-# END DEBUG
}
}
},
Added: komodo/SciViews-K-dev/R/compat.R
===================================================================
--- komodo/SciViews-K-dev/R/compat.R (rev 0)
+++ komodo/SciViews-K-dev/R/compat.R 2011-12-12 21:16:32 UTC (rev 412)
@@ -0,0 +1,31 @@
+
+if(!existsFunction("getSrcFilename", where="package:utils")) {
+ getSrcref <- function (x) {
+ if (inherits(x, "srcref"))
+ return(x)
+ if (!is.null(srcref <- attr(x, "srcref")))
+ return(srcref)
+ if (is.function(x))
+ return(getSrcref(body(x)))
+ NULL
+ }
+
+ getSrcFilename <- function (x, full.names = FALSE, unique = TRUE) {
+ srcref <- getSrcref(x)
+ if (is.list(srcref))
+ result <- sapply(srcref, getSrcFilename, full.names,
+ unique)
+ else {
+ srcfile <- attr(srcref, "srcfile")
+ if (is.null(srcfile))
+ result <- character()
+ else result <- srcfile$filename
+ }
+ result <- if (full.names)
+ result
+ else basename(result)
+ if (unique)
+ unique(result)
+ else result
+ }
+}
Added: komodo/SciViews-K-dev/R/quickParse.R
===================================================================
--- komodo/SciViews-K-dev/R/quickParse.R (rev 0)
+++ komodo/SciViews-K-dev/R/quickParse.R 2011-12-12 21:16:32 UTC (rev 412)
@@ -0,0 +1,10 @@
+`quickParse` <- function(filename, encoding = "UTF-8") {
+ if(file.exists(filename)) {
+ on.exit(close(fconn))
+ fconn <- file(filename, open = "r", encoding = encoding)
+ x <- tryCatch({ parse(file = fconn); NA }, error = function(e) e)
+ return(invisible(if(is.na(x[1L])) "" else conditionMessage(x)))
+ }
+ # be quiet about errors:
+ # else stop("File ", filename, " not found")
+}
Modified: komodo/SciViews-K-dev/components/koRLinter.py
===================================================================
--- komodo/SciViews-K-dev/components/koRLinter.py 2011-12-11 19:39:50 UTC (rev 411)
+++ komodo/SciViews-K-dev/components/koRLinter.py 2011-12-12 21:16:32 UTC (rev 412)
@@ -50,8 +50,6 @@
log = logging.getLogger('RLinter')
log.setLevel(logging.DEBUG)
-
-
#ss = s * 5000
#t0 = time.clock()
#for n in range(100):
@@ -99,12 +97,12 @@
fout = open(tmp_filename, 'wb')
fout.write(text)
fout.close()
- command = 'cat(quick.lint(\"' + tmp_filename.replace('\\', '/') + '", encoding="UTF-8"))'
+ command = 'cat(quickParse(\"' + tmp_filename.replace('\\', '/') + '", encoding = "UTF-8"))'
#log.debug(command)
except Exception, e:
log.exception(e)
try:
- lines = self.sv_utils.execInR(command, "h", 1.5).rstrip() \
+ lines = self.sv_utils.execInR(command, "json h", 1.5).rstrip() \
.replace('\x03', '').replace('\x02', '')
if lines == 'timed out':
raise ServerException(nsError.NS_ERROR_NOT_AVAILABLE)
@@ -136,4 +134,5 @@
log.exception(e)
finally:
os.unlink(tmp_filename)
+ pass
return results
Modified: komodo/SciViews-K-dev/content/RHelpWindow.xul
===================================================================
--- komodo/SciViews-K-dev/content/RHelpWindow.xul 2011-12-11 19:39:50 UTC (rev 411)
+++ komodo/SciViews-K-dev/content/RHelpWindow.xul 2011-12-12 21:16:32 UTC (rev 412)
@@ -262,6 +262,24 @@
rHelpBrowser.webNavigation.LOAD_FLAGS_NONE, null, null, null);
}
+//var cont = window._content;
+//var sel = cont.getSelection();
+//var text = sel.anchorNode.textContent;
+//var pos = sel.anchorOffset;
+//print(text.charCodeAt(pos));
+//
+//
+//var start = text[pos - 1] == '\n' ? pos - 1 : text.substr(0, pos - 1).lastIndexOf("\n") + 1;
+//if(start == -1) start = 0;
+//var end = pos + text.substr(pos, text.length).indexOf("\n");
+//
+//if(end == -1) end= text.length;
+//print(start + "," + end) print("*" + text.substring(start, end) + "*");
+//pos = cont.getSelection().anchorOffset;
+//for(var i = -3; i < 4; i++)
+// print(i + "\t" + text[pos + i] + "//"+ text.charCodeAt(pos + i));
+//-1 //10
+
function _getHomePage(browser, goTo) {
var isWin = navigator.platform.search(/Win\d+$/) === 0;
// Everything is changed in R 2.10
Modified: komodo/SciViews-K-dev/install.rdf
===================================================================
--- komodo/SciViews-K-dev/install.rdf 2011-12-11 19:39:50 UTC (rev 411)
+++ komodo/SciViews-K-dev/install.rdf 2011-12-12 21:16:32 UTC (rev 412)
@@ -4,7 +4,7 @@
<Description about="urn:mozilla:install-manifest">
<em:id>sciviewsk at sciviews.org</em:id>
<em:name>SciViews-K</em:name>
- <em:version>1.0.6dev</em:version>
+ <em:version>1.0.7dev</em:version>
<em:description>Edit R code with Komodo</em:description>
<em:creator>Philippe Grosjean</em:creator>
<em:contributor>Romain Francois</em:contributor>
Modified: komodo/SciViews-K-dev/sciviewsk-1.0.6dev-ko.xpi
===================================================================
(Binary files differ)
More information about the Sciviews-commits
mailing list