Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update built-in function match regex #1431

Merged
merged 2 commits into from
Oct 7, 2023

Conversation

MichaelChirico
Copy link
Contributor

@MichaelChirico MichaelChirico commented Sep 28, 2023

Closes #1430, Closes #1429

Code to generate:

export_matches_for_package <- function(pkg) {
  getNamespaceExports(pkg) |>
    # Drop private functions (mostly, start with '.'), operators (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")

Copied from the vscode repo on recommendation of @alexr00:

microsoft/vscode#194352

@MichaelChirico
Copy link
Contributor Author

Copying comment from upstream:


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*(\\()

@MichaelChirico MichaelChirico changed the title apply change from vscode Update built-in function match regex Sep 28, 2023
@MichaelChirico
Copy link
Contributor Author

Friendly ping @renkun-ken. Any idea a timeline I should have in mind for review/merge here?

@renkun-ken
Copy link
Member

Many thanks for working on this!

Copy link
Member

@renkun-ken renkun-ken left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM Thanks!

@renkun-ken renkun-ken merged commit ad966f3 into REditorSupport:master Oct 7, 2023
@MichaelChirico MichaelChirico deleted the builtints branch October 9, 2023 00:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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
2 participants