Skip to content

Conversation

@MichaelChirico
Copy link
Contributor

@MichaelChirico MichaelChirico commented Sep 27, 2023

Closes #194350, Closes #194355

Code to generate:

export_matches_for_package <- function(pkg) {
  getNamespaceExports(pkg) |>
    # Drop private functions (mostly, start with '.'), opreators (e.g. `%%`, `+`, `$`)
    grep(pattern = "^[a-z]", value = TRUE, ignore.case = TRUE) |>
    # Drop setters (e.g. `$<-.data.frame` or `names<-`)
    grep(pattern = "<-", value = TRUE, fixed = TRUE, invert = TRUE) |>
    # Drop built-in constants, i.e. base/R/constants.R
    setdiff(c("T", "F", "letters", "LETTERS", "month.abb", "month.name")) |>
    sort() |>
    gsub(pattern = ".", replacement = R"[\\.]", fixed = TRUE) |>
    paste(collapse = "|") |>
    paste0(R"[\\b(]", ..2 = _, R"[)\\s*(\\()]") |>
    writeLines()
}

export_matches_for_package("base")
export_matches_for_package("graphics")
export_matches_for_package("grDevices")
export_matches_for_package("methods")
export_matches_for_package("stats")
export_matches_for_package("utils")

@MichaelChirico
Copy link
Contributor Author

Note that this list only includes the default-attached packages (symbols available by default when starting R); it excludes symbols from packages available in every R installation, namely tools, grid, splines, tcltk, compiler, and parallel. It may be worth adding entries for those as well. Here are the relevant strings:

< grid >
\\b(absolute\\.size|addGrob|applyEdit|applyEdits|arcCurvature|arrow|arrowsGrob|ascentDetails|bezierGrob|bezierPoints|calcStringMetric|childNames|circleGrob|clipGrob|convertHeight|convertNative|convertUnit|convertWidth|convertX|convertY|current\\.parent|current\\.rotation|current\\.transform|current\\.viewport|current\\.vpPath|current\\.vpTree|curveGrob|dataViewport|delayGrob|depth|descentDetails|deviceDim|deviceLoc|downViewport|draw\\.details|drawDetails|editDetails|editGrob|editViewport|emptyCoords|engine\\.display\\.list|explode|forceGrob|frameGrob|functionGrob|gEdit|gEditList|get\\.gpar|getGrob|getNames|gList|gpar|gPath|grid\\.abline|grid\\.add|grid\\.arrows|grid\\.bezier|grid\\.cap|grid\\.circle|grid\\.clip|grid\\.collection|grid\\.convert|grid\\.convertHeight|grid\\.convertWidth|grid\\.convertX|grid\\.convertY|grid\\.copy|grid\\.curve|grid\\.delay|grid\\.display\\.list|grid\\.DLapply|grid\\.draw|grid\\.edit|grid\\.force|grid\\.frame|grid\\.function|grid\\.gedit|grid\\.get|grid\\.gget|grid\\.grab|grid\\.grabExpr|grid\\.gremove|grid\\.grep|grid\\.grill|grid\\.grob|grid\\.layout|grid\\.legend|grid\\.lines|grid\\.line\\.to|grid\\.locator|grid\\.ls|grid\\.move\\.to|grid\\.multipanel|grid\\.newpage|grid\\.null|grid\\.pack|grid\\.panel|grid\\.path|grid\\.place|grid\\.plot\\.and\\.legend|grid\\.points|grid\\.polygon|grid\\.polyline|grid\\.pretty|grid\\.raster|grid\\.record|grid\\.rect|grid\\.refresh|grid\\.remove|grid\\.reorder|grid\\.revert|grid\\.roundrect|grid\\.segments|grid\\.set|grid\\.show\\.layout|grid\\.show\\.viewport|grid\\.strip|grid\\.text|grid\\.xaxis|grid\\.xspline|grid\\.yaxis|grob|grobAscent|grobCoords|grobDescent|grobHeight|grobName|grobPathListing|grobPoints|grobTree|grobWidth|grobX|grobY|gTree|heightDetails|isEmptyCoords|is\\.grob|is\\.unit|layout\\.heights|layoutRegion|layout\\.torture|layout\\.widths|legendGrob|linearGradient|linesGrob|lineToGrob|makeContent|makeContext|moveToGrob|nestedListing|nullGrob|packGrob|pathGrob|pathListing|pattern|placeGrob|plotViewport|pointsGrob|polygonGrob|polylineGrob|pop\\.viewport|popViewport|postDrawDetails|preDrawDetails|push\\.viewport|pushViewport|radialGradient|rasterGrob|recordGrob|rectGrob|removeGrob|reorderGrob|resolveHJust|resolveRasterSize|resolveVJust|roundrectGrob|seekViewport|segmentsGrob|setChildren|setGrob|showGrob|showViewport|stringAscent|stringDescent|stringHeight|stringWidth|textGrob|unit|unit\\.c|unit\\.length|unit\\.pmax|unit\\.pmin|unit\\.psum|unit\\.rep|unitType|upViewport|validDetails|valid\\.just|viewport|viewport\\.layout|viewport\\.transform|vpList|vpPath|vpStack|vpTree|widthDetails|xaxisGrob|xDetails|xsplineGrob|xsplinePoints|yaxisGrob|yDetails)\\s*(\\()

< splines >
\\b(as\\.polySpline|asVector|backSpline|bs|interpSpline|ns|periodicSpline|polySpline|spline\\.des|splineDesign|splineKnots|splineOrder|xyVector)\\s*(\\()

< tcltk >
\\b(addTclPath|as\\.tclObj|getTkProgressBar|is\\.tclObj|is\\.tkwin|setTkProgressBar|tcl|tclArray|tclclose|tclfile\\.dir|tclfile\\.tail|tclObj|tclopen|tclputs|tclread|tclRequire|tclServiceMode|tclvalue|tclvar|tclVar|tclVersion|tkactivate|tkadd|tkaddtag|tkbbox|tkbell|tkbind|tkbindtags|tkbutton|tkcanvas|tkcanvasx|tkcanvasy|tkcget|tkcheckbutton|tk_choose\\.dir|tkchooseDirectory|tk_choose\\.files|tkclipboard\\.append|tkclipboard\\.clear|tkcompare|tkconfigure|tkcoords|tkcreate|tkcurselection|tkdchars|tkdebug|tkdelete|tkdelta|tkdeselect|tkdestroy|tkdialog|tkdlineinfo|tkdtag|tkdump|tkentry|tkentrycget|tkentryconfigure|tkevent\\.add|tkevent\\.delete|tkevent\\.generate|tkevent\\.info|tkfind|tkflash|tkfocus|tkfont\\.actual|tkfont\\.configure|tkfont\\.create|tkfont\\.delete|tkfont\\.families|tkfont\\.measure|tkfont\\.metrics|tkfont\\.names|tkfraction|tkframe|tkget|tkgetOpenFile|tkgetSaveFile|tkgettags|tkgrab|tkgrab\\.current|tkgrab\\.release|tkgrab\\.set|tkgrab\\.status|tkgrid|tkgrid\\.bbox|tkgrid\\.columnconfigure|tkgrid\\.configure|tkgrid\\.forget|tkgrid\\.info|tkgrid\\.location|tkgrid\\.propagate|tkgrid\\.remove|tkgrid\\.rowconfigure|tkgrid\\.size|tkgrid\\.slaves|tkicursor|tkidentify|tkimage\\.create|tkimage\\.delete|tkimage\\.height|tkimage\\.inuse|tkimage\\.names|tkimage\\.type|tkimage\\.types|tkimage\\.width|tkindex|tkinsert|tkinvoke|tkitembind|tkitemcget|tkitemconfigure|tkitemfocus|tkitemlower|tkitemraise|tkitemscale|tklabel|tklistbox|tklower|tkmark\\.gravity|tkmark\\.names|tkmark\\.next|tkmark\\.previous|tkmark\\.set|tkmark\\.unset|tkmenu|tkmenubutton|tkmessage|tkmessageBox|tk_messageBox|tkmove|tknearest|tkpack|tkpack\\.configure|tkpack\\.forget|tkpack\\.info|tkpack\\.propagate|tkpack\\.slaves|tkpager|tkplace|tkplace\\.configure|tkplace\\.forget|tkplace\\.info|tkplace\\.slaves|tkpopup|tkpost|tkpostcascade|tkpostscript|tkProgressBar|tkradiobutton|tkraise|tkscale|tkscan\\.dragto|tkscan\\.mark|tkscrollbar|tksearch|tksee|tkselect|tkselection\\.adjust|tkselection\\.anchor|tkselection\\.clear|tkselection\\.from|tkselection\\.includes|tkselection\\.present|tkselection\\.range|tkselection\\.set|tkselection\\.to|tk_select\\.list|tkset|tksize|tkStartGUI|tktag\\.add|tktag\\.bind|tktag\\.cget|tktag\\.configure|tktag\\.delete|tktag\\.lower|tktag\\.names|tktag\\.nextrange|tktag\\.prevrange|tktag\\.raise|tktag\\.ranges|tktag\\.remove|tktext|tktitle|tktoggle|tktoplevel|tktype|tkunpost|tkwait\\.variable|tkwait\\.visibility|tkwait\\.window|tkwidget|tkwindow\\.cget|tkwindow\\.configure|tkwindow\\.create|tkwindow\\.names|tkwinfo|tkwm\\.aspect|tkwm\\.client|tkwm\\.colormapwindows|tkwm\\.command|tkwm\\.deiconify|tkwm\\.focusmodel|tkwm\\.frame|tkwm\\.geometry|tkwm\\.grid|tkwm\\.group|tkwm\\.iconbitmap|tkwm\\.iconify|tkwm\\.iconmask|tkwm\\.iconname|tkwm\\.iconposition|tkwm\\.iconwindow|tkwm\\.maxsize|tkwm\\.minsize|tkwm\\.overrideredirect|tkwm\\.positionfrom|tkwm\\.protocol|tkwm\\.resizable|tkwm\\.sizefrom|tkwm\\.state|tkwm\\.title|tkwm\\.transient|tkwm\\.withdraw|tkXselection\\.clear|tkXselection\\.get|tkXselection\\.handle|tkXselection\\.own|tkxview|tkxview\\.moveto|tkxview\\.scroll|tkyposition|tkyview|tkyview\\.moveto|tkyview\\.scroll|ttkbutton|ttkcheckbutton|ttkcombobox|ttkentry|ttkframe|ttklabel|ttklabelframe|ttkmenubutton|ttknotebook|ttkpanedwindow|ttkprogressbar|ttkradiobutton|ttkscale|ttkscrollbar|ttkseparator|ttksizegrip|ttkspinbox|ttktreeview)\\s*(\\()

< compiler >
\\b(cmpfile|cmpfun|compile|compilePKGS|disassemble|enableJIT|getCompilerOption|loadcmp|setCompilerOptions)\\s*(\\()

< parallel >
\\b(clusterApply|clusterApplyLB|clusterCall|clusterEvalQ|clusterExport|clusterMap|clusterSetRNGStream|clusterSplit|detectCores|getDefaultCluster|makeCluster|makeForkCluster|makePSOCKcluster|mcaffinity|mccollect|mclapply|mcMap|mcmapply|mcparallel|mc\\.reset\\.stream|nextRNGStream|nextRNGSubStream|parApply|parCapply|parLapply|parLapplyLB|parRapply|parSapply|parSapplyLB|pvec|setDefaultCluster|splitIndices|stopCluster)\\s*(\\()

@mjbvz mjbvz assigned alexr00 and unassigned mjbvz Sep 28, 2023
@alexr00
Copy link
Member

alexr00 commented Sep 28, 2023

Thanks for the PR! We pull our syntax highlighting grammar for R from https://github.com/REditorSupport/vscode-R. If you make a PR to that repo and it gets accepted then I'll pull the changes in to VS Code.

@MichaelChirico
Copy link
Contributor Author

@alexr00 can you clarify that you'll overwrite this same file: extensions/r/syntaxes/r.tmLanguage.json? That file is the source of highlighting for us.

@MichaelChirico
Copy link
Contributor Author

Filed REditorSupport/vscode-R#1431

@MichaelChirico
Copy link
Contributor Author

MichaelChirico commented Sep 28, 2023

Btw @alexr00 note that the information in this file is already stale:

"information_for_contributors": [
"This file has been converted from https://github.com/Ikuyadeu/vscode-R/blob/master/syntax/r.json",
"If you want to provide a fix or improvement, please create a pull request against the original repository.",
"Once accepted there, we are happy to receive an update request."
],
"version": "https://github.com/Ikuyadeu/vscode-R/commit/ff60e426f66503f3c9533c7a62a8fd3f9f6c53df",

Fixed in #194415.

MichaelChirico added a commit to MichaelChirico/vscode that referenced this pull request Sep 28, 2023
This threw me off in microsoft#194352 -- I was not familiar with the original repo owner so I assumed this info was stale. The link now redirects to the REditorSupport org, but having the correct source in the plain text is still preferable for human readers.
alexr00 added a commit that referenced this pull request Oct 2, 2023
* Update org in reference repo

This threw me off in #194352 -- I was not familiar with the original repo owner so I assumed this info was stale. The link now redirects to the REditorSupport org, but having the correct source in the plain text is still preferable for human readers.

* Update template generation source

* Update R repo in cgmanifest

---------

Co-authored-by: Alex Ross <[email protected]>
@MichaelChirico MichaelChirico deleted the patch-1 branch October 9, 2023 00:31
@MichaelChirico
Copy link
Contributor Author

Thanks for the tip @alexr00, REditorSupport/vscode-R#1431 is now merged. Do we wait for a 'release' of downstream or can the changes be pulled in now?

@alexr00
Copy link
Member

alexr00 commented Oct 9, 2023

It's still early in our development iteration, so I've pulled in the changes now: #195139

Alex0007 pushed a commit to Alex0007/vscode that referenced this pull request Oct 26, 2023
* Update org in reference repo

This threw me off in microsoft#194352 -- I was not familiar with the original repo owner so I assumed this info was stale. The link now redirects to the REditorSupport org, but having the correct source in the plain text is still preferable for human readers.

* Update template generation source

* Update R repo in cgmanifest

---------

Co-authored-by: Alex Ross <[email protected]>
@github-actions github-actions bot locked and limited conversation to collaborators Nov 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

R highlighting incorrect due to bad regex Built-in functions for R are stale

3 participants