@openui5/sap.ui.codeeditor 1.120.7 → 1.121.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.reuse/dep5 +23 -21
- package/THIRDPARTY.txt +6 -43
- package/package.json +2 -2
- package/src/sap/ui/codeeditor/.library +2 -2
- package/src/sap/ui/codeeditor/CodeEditor.js +41 -27
- package/src/sap/ui/codeeditor/js/ace/ace.js +16262 -16597
- package/src/sap/ui/codeeditor/js/ace/css/ace.css +358 -86
- package/src/sap/ui/codeeditor/js/ace/css/ambiance-3.png +0 -0
- package/src/sap/ui/codeeditor/js/ace/css/chrome-2.png +0 -0
- package/src/sap/ui/codeeditor/js/ace/css/cloud9_day-1.png +0 -0
- package/src/sap/ui/codeeditor/js/ace/css/cloud9_day-2.png +0 -0
- package/src/sap/ui/codeeditor/js/ace/css/cloud9_night-1.png +0 -0
- package/src/sap/ui/codeeditor/js/ace/css/cloud9_night-2.png +0 -0
- package/src/sap/ui/codeeditor/js/ace/css/cloud9_night_low_color-1.png +0 -0
- package/src/sap/ui/codeeditor/js/ace/css/cloud9_night_low_color-2.png +0 -0
- package/src/sap/ui/codeeditor/js/ace/css/clouds-2.png +0 -0
- package/src/sap/ui/codeeditor/js/ace/css/clouds_midnight-2.png +0 -0
- package/src/sap/ui/codeeditor/js/ace/css/cobalt-2.png +0 -0
- package/src/sap/ui/codeeditor/js/ace/css/crimson_editor-2.png +0 -0
- package/src/sap/ui/codeeditor/js/ace/css/dawn-2.png +0 -0
- package/src/sap/ui/codeeditor/js/ace/css/dracula-2.png +0 -0
- package/src/sap/ui/codeeditor/js/ace/css/dreamweaver-2.png +0 -0
- package/src/sap/ui/codeeditor/js/ace/css/eclipse-2.png +0 -0
- package/src/sap/ui/codeeditor/js/ace/css/github-2.png +0 -0
- package/src/sap/ui/codeeditor/js/ace/css/github_dark-1.png +0 -0
- package/src/sap/ui/codeeditor/js/ace/css/github_dark-2.png +0 -0
- package/src/sap/ui/codeeditor/js/ace/css/gob-2.png +0 -0
- package/src/sap/ui/codeeditor/js/ace/css/gruvbox-2.png +0 -0
- package/src/sap/ui/codeeditor/js/ace/css/gruvbox_dark_hard-1.png +0 -0
- package/src/sap/ui/codeeditor/js/ace/css/gruvbox_light_hard-1.png +0 -0
- package/src/sap/ui/codeeditor/js/ace/css/gruvbox_light_hard-2.png +0 -0
- package/src/sap/ui/codeeditor/js/ace/css/idle_fingers-2.png +0 -0
- package/src/sap/ui/codeeditor/js/ace/css/iplastic-3.png +0 -0
- package/src/sap/ui/codeeditor/js/ace/css/katzenmilch-1.png +0 -0
- package/src/sap/ui/codeeditor/js/ace/css/katzenmilch-2.png +0 -0
- package/src/sap/ui/codeeditor/js/ace/css/kr_theme-2.png +0 -0
- package/src/sap/ui/codeeditor/js/ace/css/kuroir-1.png +0 -0
- package/src/sap/ui/codeeditor/js/ace/css/kuroir-2.png +0 -0
- package/src/sap/ui/codeeditor/js/ace/css/main-10.png +0 -0
- package/src/sap/ui/codeeditor/js/ace/css/main-11.png +0 -0
- package/src/sap/ui/codeeditor/js/ace/css/main-12.png +0 -0
- package/src/sap/ui/codeeditor/js/ace/css/main-13.png +0 -0
- package/src/sap/ui/codeeditor/js/ace/css/main-14.png +0 -0
- package/src/sap/ui/codeeditor/js/ace/css/main-15.png +0 -0
- package/src/sap/ui/codeeditor/js/ace/css/main-16.png +0 -0
- package/src/sap/ui/codeeditor/js/ace/css/main-17.png +0 -0
- package/src/sap/ui/codeeditor/js/ace/css/main-18.png +0 -0
- package/src/sap/ui/codeeditor/js/ace/css/main-19.png +0 -0
- package/src/sap/ui/codeeditor/js/ace/css/main-20.png +0 -0
- package/src/sap/ui/codeeditor/js/ace/css/main-21.png +0 -0
- package/src/sap/ui/codeeditor/js/ace/css/main-22.png +0 -0
- package/src/sap/ui/codeeditor/js/ace/css/main-22.svg +1 -0
- package/src/sap/ui/codeeditor/js/ace/css/main-23.png +0 -0
- package/src/sap/ui/codeeditor/js/ace/css/main-5.svg +7 -0
- package/src/sap/ui/codeeditor/js/ace/css/main-6.svg +7 -0
- package/src/sap/ui/codeeditor/js/ace/css/main-7.svg +9 -0
- package/src/sap/ui/codeeditor/js/ace/css/main-8.png +0 -0
- package/src/sap/ui/codeeditor/js/ace/css/main-8.svg +4 -0
- package/src/sap/ui/codeeditor/js/ace/css/main-9.png +0 -0
- package/src/sap/ui/codeeditor/js/ace/css/main-9.svg +4 -0
- package/src/sap/ui/codeeditor/js/ace/css/merbivore-2.png +0 -0
- package/src/sap/ui/codeeditor/js/ace/css/merbivore_soft-2.png +0 -0
- package/src/sap/ui/codeeditor/js/ace/css/mono_industrial-2.png +0 -0
- package/src/sap/ui/codeeditor/js/ace/css/monokai-2.png +0 -0
- package/src/sap/ui/codeeditor/js/ace/css/one_dark-2.png +0 -0
- package/src/sap/ui/codeeditor/js/ace/css/pastel_on_dark-2.png +0 -0
- package/src/sap/ui/codeeditor/js/ace/css/solarized_dark-2.png +0 -0
- package/src/sap/ui/codeeditor/js/ace/css/solarized_light-2.png +0 -0
- package/src/sap/ui/codeeditor/js/ace/css/sqlserver-2.png +0 -0
- package/src/sap/ui/codeeditor/js/ace/css/terminal-2.png +0 -0
- package/src/sap/ui/codeeditor/js/ace/css/textmate-2.png +0 -0
- package/src/sap/ui/codeeditor/js/ace/css/theme/ambiance.css +120 -68
- package/src/sap/ui/codeeditor/js/ace/css/theme/chaos.css +79 -66
- package/src/sap/ui/codeeditor/js/ace/css/theme/chrome.css +82 -43
- package/src/sap/ui/codeeditor/js/ace/css/theme/cloud9_day.css +160 -0
- package/src/sap/ui/codeeditor/js/ace/css/theme/cloud9_night.css +146 -0
- package/src/sap/ui/codeeditor/js/ace/css/theme/cloud9_night_low_color.css +134 -0
- package/src/sap/ui/codeeditor/js/ace/css/theme/clouds.css +59 -31
- package/src/sap/ui/codeeditor/js/ace/css/theme/clouds_midnight.css +60 -32
- package/src/sap/ui/codeeditor/js/ace/css/theme/cobalt.css +71 -38
- package/src/sap/ui/codeeditor/js/ace/css/theme/crimson_editor.css +79 -42
- package/src/sap/ui/codeeditor/js/ace/css/theme/dawn.css +70 -40
- package/src/sap/ui/codeeditor/js/ace/css/theme/dracula.css +95 -49
- package/src/sap/ui/codeeditor/js/ace/css/theme/dreamweaver.css +95 -49
- package/src/sap/ui/codeeditor/js/ace/css/theme/eclipse.css +62 -33
- package/src/sap/ui/codeeditor/js/ace/css/theme/github.css +71 -38
- package/src/sap/ui/codeeditor/js/ace/css/theme/github_dark.css +134 -0
- package/src/sap/ui/codeeditor/js/ace/css/theme/gob.css +68 -38
- package/src/sap/ui/codeeditor/js/ace/css/theme/gruvbox.css +54 -28
- package/src/sap/ui/codeeditor/js/ace/css/theme/gruvbox_dark_hard.css +163 -0
- package/src/sap/ui/codeeditor/js/ace/css/theme/gruvbox_light_hard.css +167 -0
- package/src/sap/ui/codeeditor/js/ace/css/theme/idle_fingers.css +62 -34
- package/src/sap/ui/codeeditor/js/ace/css/theme/iplastic.css +76 -45
- package/src/sap/ui/codeeditor/js/ace/css/theme/katzenmilch.css +91 -53
- package/src/sap/ui/codeeditor/js/ace/css/theme/kr_theme.css +67 -36
- package/src/sap/ui/codeeditor/js/ace/css/theme/kuroir.css +43 -17
- package/src/sap/ui/codeeditor/js/ace/css/theme/merbivore.css +57 -31
- package/src/sap/ui/codeeditor/js/ace/css/theme/merbivore_soft.css +57 -31
- package/src/sap/ui/codeeditor/js/ace/css/theme/mono_industrial.css +66 -36
- package/src/sap/ui/codeeditor/js/ace/css/theme/monokai.css +63 -35
- package/src/sap/ui/codeeditor/js/ace/css/theme/nord_dark.css +55 -29
- package/src/sap/ui/codeeditor/js/ace/css/theme/one_dark.css +88 -47
- package/src/sap/ui/codeeditor/js/ace/css/theme/pastel_on_dark.css +70 -38
- package/src/sap/ui/codeeditor/js/ace/css/theme/solarized_dark.css +52 -28
- package/src/sap/ui/codeeditor/js/ace/css/theme/solarized_light.css +55 -29
- package/src/sap/ui/codeeditor/js/ace/css/theme/sqlserver.css +90 -48
- package/src/sap/ui/codeeditor/js/ace/css/theme/terminal.css +64 -34
- package/src/sap/ui/codeeditor/js/ace/css/theme/textmate.css +82 -43
- package/src/sap/ui/codeeditor/js/ace/css/theme/tomorrow.css +61 -33
- package/src/sap/ui/codeeditor/js/ace/css/theme/tomorrow_night.css +61 -33
- package/src/sap/ui/codeeditor/js/ace/css/theme/tomorrow_night_blue.css +59 -32
- package/src/sap/ui/codeeditor/js/ace/css/theme/tomorrow_night_bright.css +71 -40
- package/src/sap/ui/codeeditor/js/ace/css/theme/tomorrow_night_eighties.css +61 -33
- package/src/sap/ui/codeeditor/js/ace/css/theme/twilight.css +66 -36
- package/src/sap/ui/codeeditor/js/ace/css/theme/vibrant_ink.css +59 -32
- package/src/sap/ui/codeeditor/js/ace/css/theme/xcode.css +54 -28
- package/src/sap/ui/codeeditor/js/ace/css/tomorrow-2.png +0 -0
- package/src/sap/ui/codeeditor/js/ace/css/tomorrow_night-2.png +0 -0
- package/src/sap/ui/codeeditor/js/ace/css/tomorrow_night_blue-2.png +0 -0
- package/src/sap/ui/codeeditor/js/ace/css/tomorrow_night_bright-2.png +0 -0
- package/src/sap/ui/codeeditor/js/ace/css/tomorrow_night_eighties-2.png +0 -0
- package/src/sap/ui/codeeditor/js/ace/css/twilight-2.png +0 -0
- package/src/sap/ui/codeeditor/js/ace/css/vibrant_ink-2.png +0 -0
- package/src/sap/ui/codeeditor/js/ace/css/xcode-2.png +0 -0
- package/src/sap/ui/codeeditor/js/ace/ext-beautify.js +90 -91
- package/src/sap/ui/codeeditor/js/ace/ext-code_lens.js +39 -75
- package/src/sap/ui/codeeditor/js/ace/ext-command_bar.js +457 -0
- package/src/sap/ui/codeeditor/js/ace/ext-elastic_tabstops_lite.js +47 -97
- package/src/sap/ui/codeeditor/js/ace/ext-emmet.js +496 -552
- package/src/sap/ui/codeeditor/js/ace/ext-hardwrap.js +47 -16
- package/src/sap/ui/codeeditor/js/ace/ext-inline_autocomplete.js +3269 -0
- package/src/sap/ui/codeeditor/js/ace/ext-keybinding_menu.js +45 -105
- package/src/sap/ui/codeeditor/js/ace/ext-language_tools.js +1438 -1128
- package/src/sap/ui/codeeditor/js/ace/ext-linking.js +8 -16
- package/src/sap/ui/codeeditor/js/ace/ext-modelist.js +198 -185
- package/src/sap/ui/codeeditor/js/ace/ext-options.js +405 -443
- package/src/sap/ui/codeeditor/js/ace/ext-prompt.js +1682 -1508
- package/src/sap/ui/codeeditor/js/ace/ext-rtl.js +26 -28
- package/src/sap/ui/codeeditor/js/ace/ext-searchbox.js +160 -332
- package/src/sap/ui/codeeditor/js/ace/ext-settings_menu.js +409 -446
- package/src/sap/ui/codeeditor/js/ace/ext-simple_tokenizer.js +45 -0
- package/src/sap/ui/codeeditor/js/ace/ext-spellcheck.js +4 -10
- package/src/sap/ui/codeeditor/js/ace/ext-split.js +41 -63
- package/src/sap/ui/codeeditor/js/ace/ext-statusbar.js +19 -27
- package/src/sap/ui/codeeditor/js/ace/ext-themelist.js +45 -41
- package/src/sap/ui/codeeditor/js/ace/ext-whitespace.js +62 -83
- package/src/sap/ui/codeeditor/js/ace/keybinding-emacs.js +442 -551
- package/src/sap/ui/codeeditor/js/ace/keybinding-sublime.js +338 -351
- package/src/sap/ui/codeeditor/js/ace/keybinding-vim.js +5242 -4758
- package/src/sap/ui/codeeditor/js/ace/keybinding-vscode.js +228 -235
- package/src/sap/ui/codeeditor/js/ace/mode-abap.js +72 -93
- package/src/sap/ui/codeeditor/js/ace/mode-abc.js +136 -164
- package/src/sap/ui/codeeditor/js/ace/mode-actionscript.js +109 -150
- package/src/sap/ui/codeeditor/js/ace/mode-ada.js +45 -74
- package/src/sap/ui/codeeditor/js/ace/mode-alda.js +77 -109
- package/src/sap/ui/codeeditor/js/ace/mode-apache_conf.js +196 -241
- package/src/sap/ui/codeeditor/js/ace/mode-apex.js +192 -247
- package/src/sap/ui/codeeditor/js/ace/mode-applescript.js +56 -102
- package/src/sap/ui/codeeditor/js/ace/mode-aql.js +85 -95
- package/src/sap/ui/codeeditor/js/ace/mode-asciidoc.js +120 -158
- package/src/sap/ui/codeeditor/js/ace/mode-asl.js +233 -298
- package/src/sap/ui/codeeditor/js/ace/mode-assembly_x86.js +78 -101
- package/src/sap/ui/codeeditor/js/ace/mode-astro.js +2414 -0
- package/src/sap/ui/codeeditor/js/ace/mode-autohotkey.js +80 -116
- package/src/sap/ui/codeeditor/js/ace/mode-batchfile.js +74 -105
- package/src/sap/ui/codeeditor/js/ace/mode-bibtex.js +318 -0
- package/src/sap/ui/codeeditor/js/ace/mode-c9search.js +72 -115
- package/src/sap/ui/codeeditor/js/ace/mode-c_cpp.js +171 -257
- package/src/sap/ui/codeeditor/js/ace/mode-cirru.js +97 -115
- package/src/sap/ui/codeeditor/js/ace/mode-clojure.js +126 -119
- package/src/sap/ui/codeeditor/js/ace/mode-cobol.js +48 -67
- package/src/sap/ui/codeeditor/js/ace/mode-coffee.js +203 -268
- package/src/sap/ui/codeeditor/js/ace/mode-coldfusion.js +1029 -1276
- package/src/sap/ui/codeeditor/js/ace/mode-crystal.js +337 -393
- package/src/sap/ui/codeeditor/js/ace/mode-csharp.js +127 -216
- package/src/sap/ui/codeeditor/js/ace/mode-csound_document.js +1539 -1569
- package/src/sap/ui/codeeditor/js/ace/mode-csound_orchestra.js +786 -898
- package/src/sap/ui/codeeditor/js/ace/mode-csound_score.js +184 -237
- package/src/sap/ui/codeeditor/js/ace/mode-csp.js +37 -37
- package/src/sap/ui/codeeditor/js/ace/mode-css.js +293 -384
- package/src/sap/ui/codeeditor/js/ace/mode-curly.js +1019 -1262
- package/src/sap/ui/codeeditor/js/ace/mode-cuttlefish.js +56 -0
- package/src/sap/ui/codeeditor/js/ace/mode-d.js +163 -233
- package/src/sap/ui/codeeditor/js/ace/mode-dart.js +330 -427
- package/src/sap/ui/codeeditor/js/ace/mode-diff.js +20 -38
- package/src/sap/ui/codeeditor/js/ace/mode-django.js +1032 -1271
- package/src/sap/ui/codeeditor/js/ace/mode-dockerfile.js +211 -284
- package/src/sap/ui/codeeditor/js/ace/mode-dot.js +131 -200
- package/src/sap/ui/codeeditor/js/ace/mode-drools.js +408 -349
- package/src/sap/ui/codeeditor/js/ace/mode-edifact.js +89 -125
- package/src/sap/ui/codeeditor/js/ace/mode-eiffel.js +47 -62
- package/src/sap/ui/codeeditor/js/ace/mode-ejs.js +1350 -1666
- package/src/sap/ui/codeeditor/js/ace/mode-elixir.js +349 -407
- package/src/sap/ui/codeeditor/js/ace/mode-elm.js +136 -168
- package/src/sap/ui/codeeditor/js/ace/mode-erlang.js +707 -881
- package/src/sap/ui/codeeditor/js/ace/mode-flix.js +164 -0
- package/src/sap/ui/codeeditor/js/ace/mode-forth.js +128 -172
- package/src/sap/ui/codeeditor/js/ace/mode-fortran.js +177 -246
- package/src/sap/ui/codeeditor/js/ace/mode-fsharp.js +92 -131
- package/src/sap/ui/codeeditor/js/ace/mode-fsl.js +91 -124
- package/src/sap/ui/codeeditor/js/ace/mode-ftl.js +813 -748
- package/src/sap/ui/codeeditor/js/ace/mode-gcode.js +52 -71
- package/src/sap/ui/codeeditor/js/ace/mode-gherkin.js +105 -119
- package/src/sap/ui/codeeditor/js/ace/mode-gitignore.js +12 -22
- package/src/sap/ui/codeeditor/js/ace/mode-glsl.js +184 -289
- package/src/sap/ui/codeeditor/js/ace/mode-gobstones.js +686 -623
- package/src/sap/ui/codeeditor/js/ace/mode-golang.js +167 -239
- package/src/sap/ui/codeeditor/js/ace/mode-graphqlschema.js +48 -88
- package/src/sap/ui/codeeditor/js/ace/mode-groovy.js +577 -471
- package/src/sap/ui/codeeditor/js/ace/mode-haml.js +1062 -1026
- package/src/sap/ui/codeeditor/js/ace/mode-handlebars.js +1061 -1305
- package/src/sap/ui/codeeditor/js/ace/mode-haskell.js +199 -255
- package/src/sap/ui/codeeditor/js/ace/mode-haskell_cabal.js +81 -87
- package/src/sap/ui/codeeditor/js/ace/mode-haxe.js +111 -184
- package/src/sap/ui/codeeditor/js/ace/mode-hjson.js +164 -199
- package/src/sap/ui/codeeditor/js/ace/mode-html.js +1009 -1239
- package/src/sap/ui/codeeditor/js/ace/mode-html_elixir.js +1402 -1705
- package/src/sap/ui/codeeditor/js/ace/mode-html_ruby.js +1390 -1706
- package/src/sap/ui/codeeditor/js/ace/mode-ini.js +58 -82
- package/src/sap/ui/codeeditor/js/ace/mode-io.js +85 -123
- package/src/sap/ui/codeeditor/js/ace/mode-ion.js +477 -0
- package/src/sap/ui/codeeditor/js/ace/mode-jack.js +109 -162
- package/src/sap/ui/codeeditor/js/ace/mode-jade.js +1339 -1344
- package/src/sap/ui/codeeditor/js/ace/mode-java.js +710 -498
- package/src/sap/ui/codeeditor/js/ace/mode-javascript.js +441 -354
- package/src/sap/ui/codeeditor/js/ace/mode-jexl.js +270 -0
- package/src/sap/ui/codeeditor/js/ace/mode-json.js +93 -147
- package/src/sap/ui/codeeditor/js/ace/mode-json5.js +128 -180
- package/src/sap/ui/codeeditor/js/ace/mode-jsoniq.js +58 -112
- package/src/sap/ui/codeeditor/js/ace/mode-jsp.js +1045 -865
- package/src/sap/ui/codeeditor/js/ace/mode-jssm.js +158 -190
- package/src/sap/ui/codeeditor/js/ace/mode-jsx.js +121 -194
- package/src/sap/ui/codeeditor/js/ace/mode-julia.js +128 -177
- package/src/sap/ui/codeeditor/js/ace/mode-kotlin.js +262 -614
- package/src/sap/ui/codeeditor/js/ace/mode-latex.js +94 -138
- package/src/sap/ui/codeeditor/js/ace/mode-latte.js +1120 -1366
- package/src/sap/ui/codeeditor/js/ace/mode-less.js +342 -442
- package/src/sap/ui/codeeditor/js/ace/mode-liquid.js +1353 -1414
- package/src/sap/ui/codeeditor/js/ace/mode-lisp.js +65 -73
- package/src/sap/ui/codeeditor/js/ace/mode-livescript.js +217 -224
- package/src/sap/ui/codeeditor/js/ace/mode-logiql.js +97 -142
- package/src/sap/ui/codeeditor/js/ace/mode-logtalk.js +187 -227
- package/src/sap/ui/codeeditor/js/ace/mode-lsl.js +99 -155
- package/src/sap/ui/codeeditor/js/ace/mode-lua.js +152 -211
- package/src/sap/ui/codeeditor/js/ace/mode-luapage.js +1167 -1470
- package/src/sap/ui/codeeditor/js/ace/mode-lucene.js +25 -34
- package/src/sap/ui/codeeditor/js/ace/mode-makefile.js +244 -282
- package/src/sap/ui/codeeditor/js/ace/mode-markdown.js +1858 -2177
- package/src/sap/ui/codeeditor/js/ace/mode-mask.js +964 -1007
- package/src/sap/ui/codeeditor/js/ace/mode-matlab.js +197 -221
- package/src/sap/ui/codeeditor/js/ace/mode-maze.js +127 -163
- package/src/sap/ui/codeeditor/js/ace/mode-mediawiki.js +464 -476
- package/src/sap/ui/codeeditor/js/ace/mode-mel.js +90 -140
- package/src/sap/ui/codeeditor/js/ace/mode-mips.js +101 -134
- package/src/sap/ui/codeeditor/js/ace/mode-mixal.js +63 -75
- package/src/sap/ui/codeeditor/js/ace/mode-mushcode.js +537 -576
- package/src/sap/ui/codeeditor/js/ace/mode-mysql.js +85 -102
- package/src/sap/ui/codeeditor/js/ace/mode-nasal.js +513 -0
- package/src/sap/ui/codeeditor/js/ace/mode-nginx.js +119 -155
- package/src/sap/ui/codeeditor/js/ace/mode-nim.js +159 -197
- package/src/sap/ui/codeeditor/js/ace/mode-nix.js +283 -375
- package/src/sap/ui/codeeditor/js/ace/mode-nsis.js +139 -172
- package/src/sap/ui/codeeditor/js/ace/mode-nunjucks.js +1138 -1378
- package/src/sap/ui/codeeditor/js/ace/mode-objectivec.js +400 -514
- package/src/sap/ui/codeeditor/js/ace/mode-ocaml.js +77 -120
- package/src/sap/ui/codeeditor/js/ace/mode-odin.js +449 -0
- package/src/sap/ui/codeeditor/js/ace/mode-partiql.js +750 -0
- package/src/sap/ui/codeeditor/js/ace/mode-pascal.js +28 -47
- package/src/sap/ui/codeeditor/js/ace/mode-perl.js +122 -185
- package/src/sap/ui/codeeditor/js/ace/mode-pgsql.js +974 -851
- package/src/sap/ui/codeeditor/js/ace/mode-php.js +2282 -1502
- package/src/sap/ui/codeeditor/js/ace/mode-php_laravel_blade.js +2463 -1696
- package/src/sap/ui/codeeditor/js/ace/mode-pig.js +133 -165
- package/src/sap/ui/codeeditor/js/ace/mode-plain_text.js +5 -10
- package/src/sap/ui/codeeditor/js/ace/mode-plsql.js +268 -0
- package/src/sap/ui/codeeditor/js/ace/mode-powershell.js +332 -183
- package/src/sap/ui/codeeditor/js/ace/mode-praat.js +168 -234
- package/src/sap/ui/codeeditor/js/ace/mode-prisma.js +292 -324
- package/src/sap/ui/codeeditor/js/ace/mode-prolog.js +180 -246
- package/src/sap/ui/codeeditor/js/ace/mode-properties.js +26 -37
- package/src/sap/ui/codeeditor/js/ace/mode-protobuf.js +232 -327
- package/src/sap/ui/codeeditor/js/ace/mode-prql.js +320 -0
- package/src/sap/ui/codeeditor/js/ace/mode-puppet.js +68 -120
- package/src/sap/ui/codeeditor/js/ace/mode-python.js +338 -370
- package/src/sap/ui/codeeditor/js/ace/mode-qml.js +244 -279
- package/src/sap/ui/codeeditor/js/ace/mode-r.js +295 -220
- package/src/sap/ui/codeeditor/js/ace/mode-raku.js +356 -433
- package/src/sap/ui/codeeditor/js/ace/mode-razor.js +1130 -1374
- package/src/sap/ui/codeeditor/js/ace/mode-rdoc.js +214 -171
- package/src/sap/ui/codeeditor/js/ace/mode-red.js +212 -274
- package/src/sap/ui/codeeditor/js/ace/mode-redshift.js +181 -220
- package/src/sap/ui/codeeditor/js/ace/mode-rhtml.js +1325 -1443
- package/src/sap/ui/codeeditor/js/ace/mode-robot.js +168 -0
- package/src/sap/ui/codeeditor/js/ace/mode-rst.js +217 -229
- package/src/sap/ui/codeeditor/js/ace/mode-ruby.js +338 -420
- package/src/sap/ui/codeeditor/js/ace/mode-rust.js +258 -155
- package/src/sap/ui/codeeditor/js/ace/mode-sac.js +349 -0
- package/src/sap/ui/codeeditor/js/ace/mode-sass.js +257 -309
- package/src/sap/ui/codeeditor/js/ace/mode-scad.js +127 -191
- package/src/sap/ui/codeeditor/js/ace/mode-scala.js +572 -468
- package/src/sap/ui/codeeditor/js/ace/mode-scheme.js +104 -126
- package/src/sap/ui/codeeditor/js/ace/mode-scrypt.js +181 -228
- package/src/sap/ui/codeeditor/js/ace/mode-scss.js +364 -472
- package/src/sap/ui/codeeditor/js/ace/mode-sh.js +204 -266
- package/src/sap/ui/codeeditor/js/ace/mode-sjs.js +477 -405
- package/src/sap/ui/codeeditor/js/ace/mode-slim.js +2631 -3161
- package/src/sap/ui/codeeditor/js/ace/mode-smarty.js +1075 -1334
- package/src/sap/ui/codeeditor/js/ace/mode-smithy.js +276 -327
- package/src/sap/ui/codeeditor/js/ace/mode-snippets.js +78 -102
- package/src/sap/ui/codeeditor/js/ace/mode-soy_template.js +1251 -1548
- package/src/sap/ui/codeeditor/js/ace/mode-space.js +47 -63
- package/src/sap/ui/codeeditor/js/ace/mode-sparql.js +139 -171
- package/src/sap/ui/codeeditor/js/ace/mode-sql.js +77 -133
- package/src/sap/ui/codeeditor/js/ace/mode-sqlserver.js +138 -192
- package/src/sap/ui/codeeditor/js/ace/mode-stylus.js +306 -338
- package/src/sap/ui/codeeditor/js/ace/mode-svg.js +642 -794
- package/src/sap/ui/codeeditor/js/ace/mode-swift.js +96 -150
- package/src/sap/ui/codeeditor/js/ace/mode-tcl.js +151 -200
- package/src/sap/ui/codeeditor/js/ace/mode-terraform.js +78 -132
- package/src/sap/ui/codeeditor/js/ace/mode-tex.js +148 -96
- package/src/sap/ui/codeeditor/js/ace/mode-textile.js +45 -70
- package/src/sap/ui/codeeditor/js/ace/mode-toml.js +63 -87
- package/src/sap/ui/codeeditor/js/ace/mode-tsx.js +462 -384
- package/src/sap/ui/codeeditor/js/ace/mode-turtle.js +119 -151
- package/src/sap/ui/codeeditor/js/ace/mode-twig.js +1099 -1350
- package/src/sap/ui/codeeditor/js/ace/mode-typescript.js +455 -376
- package/src/sap/ui/codeeditor/js/ace/mode-vala.js +382 -505
- package/src/sap/ui/codeeditor/js/ace/mode-vbscript.js +231 -264
- package/src/sap/ui/codeeditor/js/ace/mode-velocity.js +1116 -1388
- package/src/sap/ui/codeeditor/js/ace/mode-verilog.js +61 -81
- package/src/sap/ui/codeeditor/js/ace/mode-vhdl.js +57 -79
- package/src/sap/ui/codeeditor/js/ace/mode-visualforce.js +1046 -1292
- package/src/sap/ui/codeeditor/js/ace/mode-wollok.js +525 -417
- package/src/sap/ui/codeeditor/js/ace/mode-xml.js +182 -389
- package/src/sap/ui/codeeditor/js/ace/mode-xquery.js +58 -112
- package/src/sap/ui/codeeditor/js/ace/mode-yaml.js +202 -137
- package/src/sap/ui/codeeditor/js/ace/mode-zeek.js +237 -274
- package/src/sap/ui/codeeditor/js/ace/snippets/abc.js +5 -34
- package/src/sap/ui/codeeditor/js/ace/snippets/actionscript.js +5 -160
- package/src/sap/ui/codeeditor/js/ace/snippets/astro.js +9 -0
- package/src/sap/ui/codeeditor/js/ace/snippets/bibtex.js +9 -0
- package/src/sap/ui/codeeditor/js/ace/snippets/c_cpp.js +5 -134
- package/src/sap/ui/codeeditor/js/ace/snippets/clojure.js +5 -93
- package/src/sap/ui/codeeditor/js/ace/snippets/coffee.js +5 -98
- package/src/sap/ui/codeeditor/js/ace/snippets/csound_document.js +5 -13
- package/src/sap/ui/codeeditor/js/ace/snippets/csound_orchestra.js +5 -50
- package/src/sap/ui/codeeditor/js/ace/snippets/css.js +5 -970
- package/src/sap/ui/codeeditor/js/ace/snippets/cuttlefish.js +9 -0
- package/src/sap/ui/codeeditor/js/ace/snippets/dart.js +5 -86
- package/src/sap/ui/codeeditor/js/ace/snippets/diff.js +5 -14
- package/src/sap/ui/codeeditor/js/ace/snippets/django.js +5 -111
- package/src/sap/ui/codeeditor/js/ace/snippets/drools.js +5 -22
- package/src/sap/ui/codeeditor/js/ace/snippets/edifact.js +8 -246
- package/src/sap/ui/codeeditor/js/ace/snippets/erlang.js +5 -163
- package/src/sap/ui/codeeditor/js/ace/snippets/flix.js +9 -0
- package/src/sap/ui/codeeditor/js/ace/snippets/fsl.js +6 -4
- package/src/sap/ui/codeeditor/js/ace/snippets/gobstones.js +5 -1707
- package/src/sap/ui/codeeditor/js/ace/snippets/graphqlschema.js +5 -35
- package/src/sap/ui/codeeditor/js/ace/snippets/haml.js +5 -23
- package/src/sap/ui/codeeditor/js/ace/snippets/haskell.js +5 -85
- package/src/sap/ui/codeeditor/js/ace/snippets/html.js +5 -856
- package/src/sap/ui/codeeditor/js/ace/snippets/io.js +1 -3
- package/src/sap/ui/codeeditor/js/ace/snippets/ion.js +9 -0
- package/src/sap/ui/codeeditor/js/ace/snippets/java.js +5 -243
- package/src/sap/ui/codeeditor/js/ace/snippets/javascript.js +5 -198
- package/src/sap/ui/codeeditor/js/ace/snippets/jexl.js +9 -0
- package/src/sap/ui/codeeditor/js/ace/snippets/jsoniq.js +44 -41
- package/src/sap/ui/codeeditor/js/ace/snippets/jsp.js +5 -102
- package/src/sap/ui/codeeditor/js/ace/snippets/liquid.js +5 -884
- package/src/sap/ui/codeeditor/js/ace/snippets/lsl.js +5 -1235
- package/src/sap/ui/codeeditor/js/ace/snippets/lua.js +5 -24
- package/src/sap/ui/codeeditor/js/ace/snippets/makefile.js +5 -7
- package/src/sap/ui/codeeditor/js/ace/snippets/markdown.js +5 -91
- package/src/sap/ui/codeeditor/js/ace/snippets/maze.js +5 -12
- package/src/sap/ui/codeeditor/js/ace/snippets/nasal.js +9 -0
- package/src/sap/ui/codeeditor/js/ace/snippets/odin.js +9 -0
- package/src/sap/ui/codeeditor/js/ace/snippets/partiql.js +9 -0
- package/src/sap/ui/codeeditor/js/ace/snippets/perl.js +5 -350
- package/src/sap/ui/codeeditor/js/ace/snippets/php.js +5 -386
- package/src/sap/ui/codeeditor/js/ace/snippets/plsql.js +9 -0
- package/src/sap/ui/codeeditor/js/ace/snippets/prql.js +9 -0
- package/src/sap/ui/codeeditor/js/ace/snippets/python.js +5 -161
- package/src/sap/ui/codeeditor/js/ace/snippets/r.js +5 -124
- package/src/sap/ui/codeeditor/js/ace/snippets/razor.js +5 -6
- package/src/sap/ui/codeeditor/js/ace/snippets/robot.js +16 -0
- package/src/sap/ui/codeeditor/js/ace/snippets/rst.js +5 -25
- package/src/sap/ui/codeeditor/js/ace/snippets/ruby.js +5 -931
- package/src/sap/ui/codeeditor/js/ace/snippets/sac.js +9 -0
- package/src/sap/ui/codeeditor/js/ace/snippets/sh.js +5 -86
- package/src/sap/ui/codeeditor/js/ace/snippets/snippets.js +5 -12
- package/src/sap/ui/codeeditor/js/ace/snippets/sql.js +5 -29
- package/src/sap/ui/codeeditor/js/ace/snippets/sqlserver.js +5 -72
- package/src/sap/ui/codeeditor/js/ace/snippets/tcl.js +5 -95
- package/src/sap/ui/codeeditor/js/ace/snippets/tex.js +5 -193
- package/src/sap/ui/codeeditor/js/ace/snippets/textile.js +5 -33
- package/src/sap/ui/codeeditor/js/ace/snippets/vala.js +1 -2
- package/src/sap/ui/codeeditor/js/ace/snippets/velocity.js +5 -31
- package/src/sap/ui/codeeditor/js/ace/snippets/wollok.js +5 -87
- package/src/sap/ui/codeeditor/js/ace/snippets/xquery.js +44 -41
- package/src/sap/ui/codeeditor/js/ace/theme-ambiance.js +5 -172
- package/src/sap/ui/codeeditor/js/ace/theme-chaos.js +5 -150
- package/src/sap/ui/codeeditor/js/ace/theme-chrome.js +6 -123
- package/src/sap/ui/codeeditor/js/ace/theme-cloud9_day.js +19 -0
- package/src/sap/ui/codeeditor/js/ace/theme-cloud9_night.js +18 -0
- package/src/sap/ui/codeeditor/js/ace/theme-cloud9_night_low_color.js +18 -0
- package/src/sap/ui/codeeditor/js/ace/theme-clouds.js +6 -90
- package/src/sap/ui/codeeditor/js/ace/theme-clouds_midnight.js +6 -91
- package/src/sap/ui/codeeditor/js/ace/theme-cobalt.js +6 -108
- package/src/sap/ui/codeeditor/js/ace/theme-crimson_editor.js +6 -113
- package/src/sap/ui/codeeditor/js/ace/theme-dawn.js +6 -103
- package/src/sap/ui/codeeditor/js/ace/theme-dracula.js +6 -122
- package/src/sap/ui/codeeditor/js/ace/theme-dreamweaver.js +7 -137
- package/src/sap/ui/codeeditor/js/ace/theme-eclipse.js +6 -92
- package/src/sap/ui/codeeditor/js/ace/theme-github.js +7 -99
- package/src/sap/ui/codeeditor/js/ace/theme-github_dark.js +18 -0
- package/src/sap/ui/codeeditor/js/ace/theme-gob.js +6 -107
- package/src/sap/ui/codeeditor/js/ace/theme-gruvbox.js +5 -76
- package/src/sap/ui/codeeditor/js/ace/theme-gruvbox_dark_hard.js +18 -0
- package/src/sap/ui/codeeditor/js/ace/theme-gruvbox_light_hard.js +18 -0
- package/src/sap/ui/codeeditor/js/ace/theme-idle_fingers.js +6 -91
- package/src/sap/ui/codeeditor/js/ace/theme-iplastic.js +6 -116
- package/src/sap/ui/codeeditor/js/ace/theme-katzenmilch.js +6 -116
- package/src/sap/ui/codeeditor/js/ace/theme-kr_theme.js +6 -99
- package/src/sap/ui/codeeditor/js/ace/theme-kuroir.js +6 -56
- package/src/sap/ui/codeeditor/js/ace/theme-merbivore.js +6 -90
- package/src/sap/ui/codeeditor/js/ace/theme-merbivore_soft.js +6 -91
- package/src/sap/ui/codeeditor/js/ace/theme-mono_industrial.js +6 -102
- package/src/sap/ui/codeeditor/js/ace/theme-monokai.js +6 -100
- package/src/sap/ui/codeeditor/js/ace/theme-nord_dark.js +6 -89
- package/src/sap/ui/codeeditor/js/ace/theme-one_dark.js +10 -131
- package/src/sap/ui/codeeditor/js/ace/theme-pastel_on_dark.js +6 -103
- package/src/sap/ui/codeeditor/js/ace/theme-solarized_dark.js +6 -83
- package/src/sap/ui/codeeditor/js/ace/theme-solarized_light.js +6 -86
- package/src/sap/ui/codeeditor/js/ace/theme-sqlserver.js +6 -133
- package/src/sap/ui/codeeditor/js/ace/theme-terminal.js +6 -109
- package/src/sap/ui/codeeditor/js/ace/theme-textmate.js +3 -124
- package/src/sap/ui/codeeditor/js/ace/theme-tomorrow.js +6 -103
- package/src/sap/ui/codeeditor/js/ace/theme-tomorrow_night.js +6 -103
- package/src/sap/ui/codeeditor/js/ace/theme-tomorrow_night_blue.js +6 -101
- package/src/sap/ui/codeeditor/js/ace/theme-tomorrow_night_bright.js +6 -116
- package/src/sap/ui/codeeditor/js/ace/theme-tomorrow_night_eighties.js +6 -103
- package/src/sap/ui/codeeditor/js/ace/theme-twilight.js +6 -104
- package/src/sap/ui/codeeditor/js/ace/theme-vibrant_ink.js +6 -89
- package/src/sap/ui/codeeditor/js/ace/theme-xcode.js +6 -83
- package/src/sap/ui/codeeditor/js/ace/worker-base.js +516 -595
- package/src/sap/ui/codeeditor/js/ace/worker-coffee.js +496 -575
- package/src/sap/ui/codeeditor/js/ace/worker-css.js +501 -578
- package/src/sap/ui/codeeditor/js/ace/worker-html.js +515 -584
- package/src/sap/ui/codeeditor/js/ace/worker-javascript.js +2964 -2551
- package/src/sap/ui/codeeditor/js/ace/worker-json.js +496 -575
- package/src/sap/ui/codeeditor/js/ace/worker-lua.js +497 -576
- package/src/sap/ui/codeeditor/js/ace/worker-php.js +2906 -2795
- package/src/sap/ui/codeeditor/js/ace/worker-xml.js +496 -575
- package/src/sap/ui/codeeditor/js/ace/worker-xquery.js +496 -575
- package/src/sap/ui/codeeditor/js/ace/worker-yaml.js +5851 -0
- package/src/sap/ui/codeeditor/library.js +6 -5
- package/LICENSES/BSD-2-Clause.txt +0 -22
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
ace.define("ace/snippets",[], function(require, exports, module)
|
|
2
|
-
"use strict";
|
|
1
|
+
ace.define("ace/snippets",["require","exports","module","ace/lib/dom","ace/lib/oop","ace/lib/event_emitter","ace/lib/lang","ace/range","ace/range_list","ace/keyboard/hash_handler","ace/tokenizer","ace/clipboard","ace/editor"], function(require, exports, module){"use strict";
|
|
3
2
|
var dom = require("./lib/dom");
|
|
4
3
|
var oop = require("./lib/oop");
|
|
5
4
|
var EventEmitter = require("./lib/event_emitter").EventEmitter;
|
|
@@ -9,107 +8,100 @@ var RangeList = require("./range_list").RangeList;
|
|
|
9
8
|
var HashHandler = require("./keyboard/hash_handler").HashHandler;
|
|
10
9
|
var Tokenizer = require("./tokenizer").Tokenizer;
|
|
11
10
|
var clipboard = require("./clipboard");
|
|
12
|
-
|
|
13
11
|
var VARIABLES = {
|
|
14
|
-
CURRENT_WORD: function(editor) {
|
|
12
|
+
CURRENT_WORD: function (editor) {
|
|
15
13
|
return editor.session.getTextRange(editor.session.getWordRange());
|
|
16
14
|
},
|
|
17
|
-
SELECTION: function(editor, name, indentation) {
|
|
15
|
+
SELECTION: function (editor, name, indentation) {
|
|
18
16
|
var text = editor.session.getTextRange();
|
|
19
17
|
if (indentation)
|
|
20
18
|
return text.replace(/\n\r?([ \t]*\S)/g, "\n" + indentation + "$1");
|
|
21
19
|
return text;
|
|
22
20
|
},
|
|
23
|
-
CURRENT_LINE: function(editor) {
|
|
21
|
+
CURRENT_LINE: function (editor) {
|
|
24
22
|
return editor.session.getLine(editor.getCursorPosition().row);
|
|
25
23
|
},
|
|
26
|
-
PREV_LINE: function(editor) {
|
|
24
|
+
PREV_LINE: function (editor) {
|
|
27
25
|
return editor.session.getLine(editor.getCursorPosition().row - 1);
|
|
28
26
|
},
|
|
29
|
-
LINE_INDEX: function(editor) {
|
|
27
|
+
LINE_INDEX: function (editor) {
|
|
30
28
|
return editor.getCursorPosition().row;
|
|
31
29
|
},
|
|
32
|
-
LINE_NUMBER: function(editor) {
|
|
30
|
+
LINE_NUMBER: function (editor) {
|
|
33
31
|
return editor.getCursorPosition().row + 1;
|
|
34
32
|
},
|
|
35
|
-
SOFT_TABS: function(editor) {
|
|
33
|
+
SOFT_TABS: function (editor) {
|
|
36
34
|
return editor.session.getUseSoftTabs() ? "YES" : "NO";
|
|
37
35
|
},
|
|
38
|
-
TAB_SIZE: function(editor) {
|
|
36
|
+
TAB_SIZE: function (editor) {
|
|
39
37
|
return editor.session.getTabSize();
|
|
40
38
|
},
|
|
41
|
-
CLIPBOARD: function(editor) {
|
|
39
|
+
CLIPBOARD: function (editor) {
|
|
42
40
|
return clipboard.getText && clipboard.getText();
|
|
43
41
|
},
|
|
44
|
-
FILENAME: function(editor) {
|
|
42
|
+
FILENAME: function (editor) {
|
|
45
43
|
return /[^/\\]*$/.exec(this.FILEPATH(editor))[0];
|
|
46
44
|
},
|
|
47
|
-
FILENAME_BASE: function(editor) {
|
|
45
|
+
FILENAME_BASE: function (editor) {
|
|
48
46
|
return /[^/\\]*$/.exec(this.FILEPATH(editor))[0].replace(/\.[^.]*$/, "");
|
|
49
47
|
},
|
|
50
|
-
DIRECTORY: function(editor) {
|
|
48
|
+
DIRECTORY: function (editor) {
|
|
51
49
|
return this.FILEPATH(editor).replace(/[^/\\]*$/, "");
|
|
52
50
|
},
|
|
53
|
-
FILEPATH: function(editor) { return "/not implemented.txt"; },
|
|
54
|
-
WORKSPACE_NAME: function() { return "Unknown"; },
|
|
55
|
-
FULLNAME: function() { return "Unknown"; },
|
|
56
|
-
BLOCK_COMMENT_START: function(editor) {
|
|
51
|
+
FILEPATH: function (editor) { return "/not implemented.txt"; },
|
|
52
|
+
WORKSPACE_NAME: function () { return "Unknown"; },
|
|
53
|
+
FULLNAME: function () { return "Unknown"; },
|
|
54
|
+
BLOCK_COMMENT_START: function (editor) {
|
|
57
55
|
var mode = editor.session.$mode || {};
|
|
58
56
|
return mode.blockComment && mode.blockComment.start || "";
|
|
59
57
|
},
|
|
60
|
-
BLOCK_COMMENT_END: function(editor) {
|
|
58
|
+
BLOCK_COMMENT_END: function (editor) {
|
|
61
59
|
var mode = editor.session.$mode || {};
|
|
62
60
|
return mode.blockComment && mode.blockComment.end || "";
|
|
63
61
|
},
|
|
64
|
-
LINE_COMMENT: function(editor) {
|
|
62
|
+
LINE_COMMENT: function (editor) {
|
|
65
63
|
var mode = editor.session.$mode || {};
|
|
66
64
|
return mode.lineCommentStart || "";
|
|
67
65
|
},
|
|
68
|
-
CURRENT_YEAR: date.bind(null, {year: "numeric"}),
|
|
69
|
-
CURRENT_YEAR_SHORT: date.bind(null, {year: "2-digit"}),
|
|
70
|
-
CURRENT_MONTH: date.bind(null, {month: "numeric"}),
|
|
71
|
-
CURRENT_MONTH_NAME: date.bind(null, {month: "long"}),
|
|
72
|
-
CURRENT_MONTH_NAME_SHORT: date.bind(null, {month: "short"}),
|
|
73
|
-
CURRENT_DATE: date.bind(null, {day: "2-digit"}),
|
|
74
|
-
CURRENT_DAY_NAME: date.bind(null, {weekday: "long"}),
|
|
75
|
-
CURRENT_DAY_NAME_SHORT: date.bind(null, {weekday: "short"}),
|
|
76
|
-
CURRENT_HOUR: date.bind(null, {hour: "2-digit", hour12: false}),
|
|
77
|
-
CURRENT_MINUTE: date.bind(null, {minute: "2-digit"}),
|
|
78
|
-
CURRENT_SECOND: date.bind(null, {second: "2-digit"})
|
|
66
|
+
CURRENT_YEAR: date.bind(null, { year: "numeric" }),
|
|
67
|
+
CURRENT_YEAR_SHORT: date.bind(null, { year: "2-digit" }),
|
|
68
|
+
CURRENT_MONTH: date.bind(null, { month: "numeric" }),
|
|
69
|
+
CURRENT_MONTH_NAME: date.bind(null, { month: "long" }),
|
|
70
|
+
CURRENT_MONTH_NAME_SHORT: date.bind(null, { month: "short" }),
|
|
71
|
+
CURRENT_DATE: date.bind(null, { day: "2-digit" }),
|
|
72
|
+
CURRENT_DAY_NAME: date.bind(null, { weekday: "long" }),
|
|
73
|
+
CURRENT_DAY_NAME_SHORT: date.bind(null, { weekday: "short" }),
|
|
74
|
+
CURRENT_HOUR: date.bind(null, { hour: "2-digit", hour12: false }),
|
|
75
|
+
CURRENT_MINUTE: date.bind(null, { minute: "2-digit" }),
|
|
76
|
+
CURRENT_SECOND: date.bind(null, { second: "2-digit" })
|
|
79
77
|
};
|
|
80
|
-
|
|
81
78
|
VARIABLES.SELECTED_TEXT = VARIABLES.SELECTION;
|
|
82
|
-
|
|
83
79
|
function date(dateFormat) {
|
|
84
80
|
var str = new Date().toLocaleString("en-us", dateFormat);
|
|
85
81
|
return str.length == 1 ? "0" + str : str;
|
|
86
82
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
oop.implement(this, EventEmitter);
|
|
95
|
-
|
|
96
|
-
this.getTokenizer = function() {
|
|
83
|
+
var SnippetManager = /** @class */ (function () {
|
|
84
|
+
function SnippetManager() {
|
|
85
|
+
this.snippetMap = {};
|
|
86
|
+
this.snippetNameMap = {};
|
|
87
|
+
this.variables = VARIABLES;
|
|
88
|
+
}
|
|
89
|
+
SnippetManager.prototype.getTokenizer = function () {
|
|
97
90
|
return SnippetManager.$tokenizer || this.createTokenizer();
|
|
98
91
|
};
|
|
99
|
-
|
|
100
|
-
this.createTokenizer = function() {
|
|
92
|
+
SnippetManager.prototype.createTokenizer = function () {
|
|
101
93
|
function TabstopToken(str) {
|
|
102
94
|
str = str.substr(1);
|
|
103
95
|
if (/^\d+$/.test(str))
|
|
104
|
-
return [{tabstopId: parseInt(str, 10)}];
|
|
105
|
-
return [{text: str}];
|
|
96
|
+
return [{ tabstopId: parseInt(str, 10) }];
|
|
97
|
+
return [{ text: str }];
|
|
106
98
|
}
|
|
107
99
|
function escape(ch) {
|
|
108
100
|
return "(?:[^\\\\" + ch + "]|\\\\.)";
|
|
109
101
|
}
|
|
110
102
|
var formatMatcher = {
|
|
111
|
-
regex: "/(" + escape("/") + "+)/",
|
|
112
|
-
onMatch: function(val, state, stack) {
|
|
103
|
+
regex: "/(" + escape("/") + "+)/",
|
|
104
|
+
onMatch: function (val, state, stack) {
|
|
113
105
|
var ts = stack[0];
|
|
114
106
|
ts.fmtString = true;
|
|
115
107
|
ts.guard = val.slice(1, -1);
|
|
@@ -118,118 +110,115 @@ var SnippetManager = function() {
|
|
|
118
110
|
},
|
|
119
111
|
next: "formatString"
|
|
120
112
|
};
|
|
121
|
-
|
|
122
113
|
SnippetManager.$tokenizer = new Tokenizer({
|
|
123
114
|
start: [
|
|
124
|
-
{regex: /\\./, onMatch: function(val, state, stack) {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
{regex:
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
115
|
+
{ regex: /\\./, onMatch: function (val, state, stack) {
|
|
116
|
+
var ch = val[1];
|
|
117
|
+
if (ch == "}" && stack.length) {
|
|
118
|
+
val = ch;
|
|
119
|
+
}
|
|
120
|
+
else if ("`$\\".indexOf(ch) != -1) {
|
|
121
|
+
val = ch;
|
|
122
|
+
}
|
|
123
|
+
return [val];
|
|
124
|
+
} },
|
|
125
|
+
{ regex: /}/, onMatch: function (val, state, stack) {
|
|
126
|
+
return [stack.length ? stack.shift() : val];
|
|
127
|
+
} },
|
|
128
|
+
{ regex: /\$(?:\d+|\w+)/, onMatch: TabstopToken },
|
|
129
|
+
{ regex: /\$\{[\dA-Z_a-z]+/, onMatch: function (str, state, stack) {
|
|
130
|
+
var t = TabstopToken(str.substr(1));
|
|
131
|
+
stack.unshift(t[0]);
|
|
132
|
+
return t;
|
|
133
|
+
}, next: "snippetVar" },
|
|
134
|
+
{ regex: /\n/, token: "newline", merge: false }
|
|
143
135
|
],
|
|
144
136
|
snippetVar: [
|
|
145
|
-
{regex: "\\|" + escape("\\|") + "*\\|", onMatch: function(val, state, stack) {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
137
|
+
{ regex: "\\|" + escape("\\|") + "*\\|", onMatch: function (val, state, stack) {
|
|
138
|
+
var choices = val.slice(1, -1).replace(/\\[,|\\]|,/g, function (operator) {
|
|
139
|
+
return operator.length == 2 ? operator[1] : "\x00";
|
|
140
|
+
}).split("\x00").map(function (value) {
|
|
141
|
+
return { value: value };
|
|
142
|
+
});
|
|
143
|
+
stack[0].choices = choices;
|
|
144
|
+
return [choices[0]];
|
|
145
|
+
}, next: "start" },
|
|
154
146
|
formatMatcher,
|
|
155
|
-
{regex: "([^:}\\\\]|\\\\.)*:?", token: "", next: "start"}
|
|
147
|
+
{ regex: "([^:}\\\\]|\\\\.)*:?", token: "", next: "start" }
|
|
156
148
|
],
|
|
157
149
|
formatString: [
|
|
158
|
-
{regex: /:/, onMatch: function(val, state, stack) {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
{regex: /\\./, onMatch: function(val, state, stack) {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
{regex: "/\\w*}", onMatch: function(val, state, stack) {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
{regex: /\$(?:\d+|\w+)/, onMatch: function(val, state, stack) {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
{regex: /\${\w+/, onMatch: function(val, state, stack) {
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
{regex: /\n/, token: "newline", merge: false},
|
|
196
|
-
{regex: /}/, onMatch: function(val, state, stack) {
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
150
|
+
{ regex: /:/, onMatch: function (val, state, stack) {
|
|
151
|
+
if (stack.length && stack[0].expectElse) {
|
|
152
|
+
stack[0].expectElse = false;
|
|
153
|
+
stack[0].ifEnd = { elseEnd: stack[0] };
|
|
154
|
+
return [stack[0].ifEnd];
|
|
155
|
+
}
|
|
156
|
+
return ":";
|
|
157
|
+
} },
|
|
158
|
+
{ regex: /\\./, onMatch: function (val, state, stack) {
|
|
159
|
+
var ch = val[1];
|
|
160
|
+
if (ch == "}" && stack.length)
|
|
161
|
+
val = ch;
|
|
162
|
+
else if ("`$\\".indexOf(ch) != -1)
|
|
163
|
+
val = ch;
|
|
164
|
+
else if (ch == "n")
|
|
165
|
+
val = "\n";
|
|
166
|
+
else if (ch == "t")
|
|
167
|
+
val = "\t";
|
|
168
|
+
else if ("ulULE".indexOf(ch) != -1)
|
|
169
|
+
val = { changeCase: ch, local: ch > "a" };
|
|
170
|
+
return [val];
|
|
171
|
+
} },
|
|
172
|
+
{ regex: "/\\w*}", onMatch: function (val, state, stack) {
|
|
173
|
+
var next = stack.shift();
|
|
174
|
+
if (next)
|
|
175
|
+
next.flag = val.slice(1, -1);
|
|
176
|
+
this.next = next && next.tabstopId ? "start" : "";
|
|
177
|
+
return [next || val];
|
|
178
|
+
}, next: "start" },
|
|
179
|
+
{ regex: /\$(?:\d+|\w+)/, onMatch: function (val, state, stack) {
|
|
180
|
+
return [{ text: val.slice(1) }];
|
|
181
|
+
} },
|
|
182
|
+
{ regex: /\${\w+/, onMatch: function (val, state, stack) {
|
|
183
|
+
var token = { text: val.slice(2) };
|
|
184
|
+
stack.unshift(token);
|
|
185
|
+
return [token];
|
|
186
|
+
}, next: "formatStringVar" },
|
|
187
|
+
{ regex: /\n/, token: "newline", merge: false },
|
|
188
|
+
{ regex: /}/, onMatch: function (val, state, stack) {
|
|
189
|
+
var next = stack.shift();
|
|
190
|
+
this.next = next && next.tabstopId ? "start" : "";
|
|
191
|
+
return [next || val];
|
|
192
|
+
}, next: "start" }
|
|
201
193
|
],
|
|
202
194
|
formatStringVar: [
|
|
203
|
-
{regex: /:\/\w+}/, onMatch: function(val, state, stack) {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
195
|
+
{ regex: /:\/\w+}/, onMatch: function (val, state, stack) {
|
|
196
|
+
var ts = stack[0];
|
|
197
|
+
ts.formatFunction = val.slice(2, -1);
|
|
198
|
+
return [stack.shift()];
|
|
199
|
+
}, next: "formatString" },
|
|
208
200
|
formatMatcher,
|
|
209
|
-
{regex: /:[\?\-+]?/, onMatch: function(val, state, stack) {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
{regex: "([^:}\\\\]|\\\\.)*:?", token: "", next: "formatString"}
|
|
201
|
+
{ regex: /:[\?\-+]?/, onMatch: function (val, state, stack) {
|
|
202
|
+
if (val[1] == "+")
|
|
203
|
+
stack[0].ifEnd = stack[0];
|
|
204
|
+
if (val[1] == "?")
|
|
205
|
+
stack[0].expectElse = true;
|
|
206
|
+
}, next: "formatString" },
|
|
207
|
+
{ regex: "([^:}\\\\]|\\\\.)*:?", token: "", next: "formatString" }
|
|
216
208
|
]
|
|
217
209
|
});
|
|
218
210
|
return SnippetManager.$tokenizer;
|
|
219
211
|
};
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
return this.getTokenizer().getLineTokens(str, startState).tokens.map(function(x) {
|
|
212
|
+
SnippetManager.prototype.tokenizeTmSnippet = function (str, startState) {
|
|
213
|
+
return this.getTokenizer().getLineTokens(str, startState).tokens.map(function (x) {
|
|
223
214
|
return x.value || x;
|
|
224
215
|
});
|
|
225
216
|
};
|
|
226
|
-
|
|
227
|
-
this.getVariableValue = function(editor, name, indentation) {
|
|
217
|
+
SnippetManager.prototype.getVariableValue = function (editor, name, indentation) {
|
|
228
218
|
if (/^\d+$/.test(name))
|
|
229
219
|
return (this.variables.__ || {})[name] || "";
|
|
230
220
|
if (/^[A-Z]\d+$/.test(name))
|
|
231
221
|
return (this.variables[name[0] + "__"] || {})[name.substr(1)] || "";
|
|
232
|
-
|
|
233
222
|
name = name.replace(/^TM_/, "");
|
|
234
223
|
if (!this.variables.hasOwnProperty(name))
|
|
235
224
|
return "";
|
|
@@ -238,21 +227,20 @@ var SnippetManager = function() {
|
|
|
238
227
|
value = this.variables[name](editor, name, indentation);
|
|
239
228
|
return value == null ? "" : value;
|
|
240
229
|
};
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
if (!ch.fmt) return str;
|
|
230
|
+
SnippetManager.prototype.tmStrFormat = function (str, ch, editor) {
|
|
231
|
+
if (!ch.fmt)
|
|
232
|
+
return str;
|
|
245
233
|
var flag = ch.flag || "";
|
|
246
234
|
var re = ch.guard;
|
|
247
235
|
re = new RegExp(re, flag.replace(/[^gim]/g, ""));
|
|
248
236
|
var fmtTokens = typeof ch.fmt == "string" ? this.tokenizeTmSnippet(ch.fmt, "formatString") : ch.fmt;
|
|
249
237
|
var _self = this;
|
|
250
|
-
var formatted = str.replace(re, function() {
|
|
238
|
+
var formatted = str.replace(re, function () {
|
|
251
239
|
var oldArgs = _self.variables.__;
|
|
252
240
|
_self.variables.__ = [].slice.call(arguments);
|
|
253
241
|
var fmtParts = _self.resolveVariables(fmtTokens, editor);
|
|
254
242
|
var gChangeCase = "E";
|
|
255
|
-
for (var i
|
|
243
|
+
for (var i = 0; i < fmtParts.length; i++) {
|
|
256
244
|
var ch = fmtParts[i];
|
|
257
245
|
if (typeof ch == "object") {
|
|
258
246
|
fmtParts[i] = "";
|
|
@@ -265,12 +253,15 @@ var SnippetManager = function() {
|
|
|
265
253
|
fmtParts[i] = next[0].toLowerCase();
|
|
266
254
|
fmtParts[i + 1] = next.substr(1);
|
|
267
255
|
}
|
|
268
|
-
}
|
|
256
|
+
}
|
|
257
|
+
else if (ch.changeCase) {
|
|
269
258
|
gChangeCase = ch.changeCase;
|
|
270
259
|
}
|
|
271
|
-
}
|
|
260
|
+
}
|
|
261
|
+
else if (gChangeCase == "U") {
|
|
272
262
|
fmtParts[i] = ch.toUpperCase();
|
|
273
|
-
}
|
|
263
|
+
}
|
|
264
|
+
else if (gChangeCase == "L") {
|
|
274
265
|
fmtParts[i] = ch.toLowerCase();
|
|
275
266
|
}
|
|
276
267
|
}
|
|
@@ -279,16 +270,14 @@ var SnippetManager = function() {
|
|
|
279
270
|
});
|
|
280
271
|
return formatted;
|
|
281
272
|
};
|
|
282
|
-
|
|
283
|
-
this.tmFormatFunction = function(str, ch, editor) {
|
|
273
|
+
SnippetManager.prototype.tmFormatFunction = function (str, ch, editor) {
|
|
284
274
|
if (ch.formatFunction == "upcase")
|
|
285
275
|
return str.toUpperCase();
|
|
286
276
|
if (ch.formatFunction == "downcase")
|
|
287
277
|
return str.toLowerCase();
|
|
288
278
|
return str;
|
|
289
279
|
};
|
|
290
|
-
|
|
291
|
-
this.resolveVariables = function(snippet, editor) {
|
|
280
|
+
SnippetManager.prototype.resolveVariables = function (snippet, editor) {
|
|
292
281
|
var result = [];
|
|
293
282
|
var indentation = "";
|
|
294
283
|
var afterNewLine = true;
|
|
@@ -306,34 +295,37 @@ var SnippetManager = function() {
|
|
|
306
295
|
}
|
|
307
296
|
continue;
|
|
308
297
|
}
|
|
309
|
-
if (!ch)
|
|
298
|
+
if (!ch)
|
|
299
|
+
continue;
|
|
310
300
|
afterNewLine = false;
|
|
311
|
-
|
|
312
301
|
if (ch.fmtString) {
|
|
313
302
|
var j = snippet.indexOf(ch, i + 1);
|
|
314
|
-
if (j == -1)
|
|
303
|
+
if (j == -1)
|
|
304
|
+
j = snippet.length;
|
|
315
305
|
ch.fmt = snippet.slice(i + 1, j);
|
|
316
306
|
i = j;
|
|
317
307
|
}
|
|
318
|
-
|
|
319
308
|
if (ch.text) {
|
|
320
309
|
var value = this.getVariableValue(editor, ch.text, indentation) + "";
|
|
321
310
|
if (ch.fmtString)
|
|
322
311
|
value = this.tmStrFormat(value, ch, editor);
|
|
323
312
|
if (ch.formatFunction)
|
|
324
313
|
value = this.tmFormatFunction(value, ch, editor);
|
|
325
|
-
|
|
326
314
|
if (value && !ch.ifEnd) {
|
|
327
315
|
result.push(value);
|
|
328
316
|
gotoNext(ch);
|
|
329
|
-
}
|
|
317
|
+
}
|
|
318
|
+
else if (!value && ch.ifEnd) {
|
|
330
319
|
gotoNext(ch.ifEnd);
|
|
331
320
|
}
|
|
332
|
-
}
|
|
321
|
+
}
|
|
322
|
+
else if (ch.elseEnd) {
|
|
333
323
|
gotoNext(ch.elseEnd);
|
|
334
|
-
}
|
|
324
|
+
}
|
|
325
|
+
else if (ch.tabstopId != null) {
|
|
335
326
|
result.push(ch);
|
|
336
|
-
}
|
|
327
|
+
}
|
|
328
|
+
else if (ch.changeCase != null) {
|
|
337
329
|
result.push(ch);
|
|
338
330
|
}
|
|
339
331
|
}
|
|
@@ -344,142 +336,35 @@ var SnippetManager = function() {
|
|
|
344
336
|
}
|
|
345
337
|
return result;
|
|
346
338
|
};
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
if (cursor.column < indentString.length)
|
|
355
|
-
indentString = indentString.slice(0, cursor.column);
|
|
356
|
-
|
|
357
|
-
snippetText = snippetText.replace(/\r/g, "");
|
|
358
|
-
var tokens = this.tokenizeTmSnippet(snippetText);
|
|
359
|
-
tokens = this.resolveVariables(tokens, editor);
|
|
360
|
-
tokens = tokens.map(function(x) {
|
|
361
|
-
if (x == "\n")
|
|
362
|
-
return x + indentString;
|
|
363
|
-
if (typeof x == "string")
|
|
364
|
-
return x.replace(/\t/g, tabString);
|
|
365
|
-
return x;
|
|
366
|
-
});
|
|
367
|
-
var tabstops = [];
|
|
368
|
-
tokens.forEach(function(p, i) {
|
|
369
|
-
if (typeof p != "object")
|
|
370
|
-
return;
|
|
371
|
-
var id = p.tabstopId;
|
|
372
|
-
var ts = tabstops[id];
|
|
373
|
-
if (!ts) {
|
|
374
|
-
ts = tabstops[id] = [];
|
|
375
|
-
ts.index = id;
|
|
376
|
-
ts.value = "";
|
|
377
|
-
ts.parents = {};
|
|
378
|
-
}
|
|
379
|
-
if (ts.indexOf(p) !== -1)
|
|
380
|
-
return;
|
|
381
|
-
if (p.choices && !ts.choices)
|
|
382
|
-
ts.choices = p.choices;
|
|
383
|
-
ts.push(p);
|
|
384
|
-
var i1 = tokens.indexOf(p, i + 1);
|
|
385
|
-
if (i1 === -1)
|
|
386
|
-
return;
|
|
387
|
-
|
|
388
|
-
var value = tokens.slice(i + 1, i1);
|
|
389
|
-
var isNested = value.some(function(t) {return typeof t === "object";});
|
|
390
|
-
if (isNested && !ts.value) {
|
|
391
|
-
ts.value = value;
|
|
392
|
-
} else if (value.length && (!ts.value || typeof ts.value !== "string")) {
|
|
393
|
-
ts.value = value.join("");
|
|
394
|
-
}
|
|
395
|
-
});
|
|
396
|
-
tabstops.forEach(function(ts) {ts.length = 0;});
|
|
397
|
-
var expanding = {};
|
|
398
|
-
function copyValue(val) {
|
|
399
|
-
var copy = [];
|
|
400
|
-
for (var i = 0; i < val.length; i++) {
|
|
401
|
-
var p = val[i];
|
|
402
|
-
if (typeof p == "object") {
|
|
403
|
-
if (expanding[p.tabstopId])
|
|
404
|
-
continue;
|
|
405
|
-
var j = val.lastIndexOf(p, i - 1);
|
|
406
|
-
p = copy[j] || {tabstopId: p.tabstopId};
|
|
407
|
-
}
|
|
408
|
-
copy[i] = p;
|
|
409
|
-
}
|
|
410
|
-
return copy;
|
|
411
|
-
}
|
|
412
|
-
for (var i = 0; i < tokens.length; i++) {
|
|
413
|
-
var p = tokens[i];
|
|
414
|
-
if (typeof p != "object")
|
|
415
|
-
continue;
|
|
416
|
-
var id = p.tabstopId;
|
|
417
|
-
var ts = tabstops[id];
|
|
418
|
-
var i1 = tokens.indexOf(p, i + 1);
|
|
419
|
-
if (expanding[id]) {
|
|
420
|
-
if (expanding[id] === p) {
|
|
421
|
-
delete expanding[id];
|
|
422
|
-
Object.keys(expanding).forEach(function(parentId) {
|
|
423
|
-
ts.parents[parentId] = true;
|
|
424
|
-
});
|
|
425
|
-
}
|
|
426
|
-
continue;
|
|
427
|
-
}
|
|
428
|
-
expanding[id] = p;
|
|
429
|
-
var value = ts.value;
|
|
430
|
-
if (typeof value !== "string")
|
|
431
|
-
value = copyValue(value);
|
|
432
|
-
else if (p.fmt)
|
|
433
|
-
value = this.tmStrFormat(value, p, editor);
|
|
434
|
-
tokens.splice.apply(tokens, [i + 1, Math.max(0, i1 - i)].concat(value, p));
|
|
435
|
-
|
|
436
|
-
if (ts.indexOf(p) === -1)
|
|
437
|
-
ts.push(p);
|
|
438
|
-
}
|
|
439
|
-
var row = 0, column = 0;
|
|
440
|
-
var text = "";
|
|
441
|
-
tokens.forEach(function(t) {
|
|
442
|
-
if (typeof t === "string") {
|
|
443
|
-
var lines = t.split("\n");
|
|
444
|
-
if (lines.length > 1){
|
|
445
|
-
column = lines[lines.length - 1].length;
|
|
446
|
-
row += lines.length - 1;
|
|
447
|
-
} else
|
|
448
|
-
column += t.length;
|
|
449
|
-
text += t;
|
|
450
|
-
} else if (t) {
|
|
451
|
-
if (!t.start)
|
|
452
|
-
t.start = {row: row, column: column};
|
|
453
|
-
else
|
|
454
|
-
t.end = {row: row, column: column};
|
|
455
|
-
}
|
|
456
|
-
});
|
|
339
|
+
SnippetManager.prototype.getDisplayTextForSnippet = function (editor, snippetText) {
|
|
340
|
+
var processedSnippet = processSnippetText.call(this, editor, snippetText);
|
|
341
|
+
return processedSnippet.text;
|
|
342
|
+
};
|
|
343
|
+
SnippetManager.prototype.insertSnippetForSelection = function (editor, snippetText, options) {
|
|
344
|
+
if (options === void 0) { options = {}; }
|
|
345
|
+
var processedSnippet = processSnippetText.call(this, editor, snippetText, options);
|
|
457
346
|
var range = editor.getSelectionRange();
|
|
458
|
-
var end = editor.session.replace(range, text);
|
|
459
|
-
|
|
347
|
+
var end = editor.session.replace(range, processedSnippet.text);
|
|
460
348
|
var tabstopManager = new TabstopManager(editor);
|
|
461
349
|
var selectionId = editor.inVirtualSelectionMode && editor.selection.index;
|
|
462
|
-
tabstopManager.addTabstops(tabstops, range.start, end, selectionId);
|
|
350
|
+
tabstopManager.addTabstops(processedSnippet.tabstops, range.start, end, selectionId);
|
|
463
351
|
};
|
|
464
|
-
|
|
465
|
-
|
|
352
|
+
SnippetManager.prototype.insertSnippet = function (editor, snippetText, options) {
|
|
353
|
+
if (options === void 0) { options = {}; }
|
|
466
354
|
var self = this;
|
|
467
355
|
if (editor.inVirtualSelectionMode)
|
|
468
|
-
return self.insertSnippetForSelection(editor, snippetText);
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
}, null, {keepOrder: true});
|
|
473
|
-
|
|
356
|
+
return self.insertSnippetForSelection(editor, snippetText, options);
|
|
357
|
+
editor.forEachSelection(function () {
|
|
358
|
+
self.insertSnippetForSelection(editor, snippetText, options);
|
|
359
|
+
}, null, { keepOrder: true });
|
|
474
360
|
if (editor.tabstopManager)
|
|
475
361
|
editor.tabstopManager.tabNext();
|
|
476
362
|
};
|
|
477
|
-
|
|
478
|
-
this.$getScope = function(editor) {
|
|
363
|
+
SnippetManager.prototype.$getScope = function (editor) {
|
|
479
364
|
var scope = editor.session.$mode.$id || "";
|
|
480
365
|
scope = scope.split("/").pop();
|
|
481
366
|
if (scope === "html" || scope === "php") {
|
|
482
|
-
if (scope === "php" && !editor.session.$mode.inlinePhp)
|
|
367
|
+
if (scope === "php" && !editor.session.$mode.inlinePhp)
|
|
483
368
|
scope = "html";
|
|
484
369
|
var c = editor.getCursorPosition();
|
|
485
370
|
var state = editor.session.getState(c.row);
|
|
@@ -495,11 +380,9 @@ var SnippetManager = function() {
|
|
|
495
380
|
scope = "php";
|
|
496
381
|
}
|
|
497
382
|
}
|
|
498
|
-
|
|
499
383
|
return scope;
|
|
500
384
|
};
|
|
501
|
-
|
|
502
|
-
this.getActiveScopes = function(editor) {
|
|
385
|
+
SnippetManager.prototype.getActiveScopes = function (editor) {
|
|
503
386
|
var scope = this.$getScope(editor);
|
|
504
387
|
var scopes = [scope];
|
|
505
388
|
var snippetMap = this.snippetMap;
|
|
@@ -509,26 +392,23 @@ var SnippetManager = function() {
|
|
|
509
392
|
scopes.push("_");
|
|
510
393
|
return scopes;
|
|
511
394
|
};
|
|
512
|
-
|
|
513
|
-
this.expandWithTab = function(editor, options) {
|
|
395
|
+
SnippetManager.prototype.expandWithTab = function (editor, options) {
|
|
514
396
|
var self = this;
|
|
515
|
-
var result = editor.forEachSelection(function() {
|
|
397
|
+
var result = editor.forEachSelection(function () {
|
|
516
398
|
return self.expandSnippetForSelection(editor, options);
|
|
517
|
-
}, null, {keepOrder: true});
|
|
399
|
+
}, null, { keepOrder: true });
|
|
518
400
|
if (result && editor.tabstopManager)
|
|
519
401
|
editor.tabstopManager.tabNext();
|
|
520
402
|
return result;
|
|
521
403
|
};
|
|
522
|
-
|
|
523
|
-
this.expandSnippetForSelection = function(editor, options) {
|
|
404
|
+
SnippetManager.prototype.expandSnippetForSelection = function (editor, options) {
|
|
524
405
|
var cursor = editor.getCursorPosition();
|
|
525
406
|
var line = editor.session.getLine(cursor.row);
|
|
526
407
|
var before = line.substring(0, cursor.column);
|
|
527
408
|
var after = line.substr(cursor.column);
|
|
528
|
-
|
|
529
409
|
var snippetMap = this.snippetMap;
|
|
530
410
|
var snippet;
|
|
531
|
-
this.getActiveScopes(editor).some(function(scope) {
|
|
411
|
+
this.getActiveScopes(editor).some(function (scope) {
|
|
532
412
|
var snippets = snippetMap[scope];
|
|
533
413
|
if (snippets)
|
|
534
414
|
snippet = this.findMatchingSnippet(snippets, before, after);
|
|
@@ -538,20 +418,14 @@ var SnippetManager = function() {
|
|
|
538
418
|
return false;
|
|
539
419
|
if (options && options.dryRun)
|
|
540
420
|
return true;
|
|
541
|
-
editor.session.doc.removeInLine(cursor.row,
|
|
542
|
-
cursor.column - snippet.replaceBefore.length,
|
|
543
|
-
cursor.column + snippet.replaceAfter.length
|
|
544
|
-
);
|
|
545
|
-
|
|
421
|
+
editor.session.doc.removeInLine(cursor.row, cursor.column - snippet.replaceBefore.length, cursor.column + snippet.replaceAfter.length);
|
|
546
422
|
this.variables.M__ = snippet.matchBefore;
|
|
547
423
|
this.variables.T__ = snippet.matchAfter;
|
|
548
424
|
this.insertSnippetForSelection(editor, snippet.content);
|
|
549
|
-
|
|
550
425
|
this.variables.M__ = this.variables.T__ = null;
|
|
551
426
|
return true;
|
|
552
427
|
};
|
|
553
|
-
|
|
554
|
-
this.findMatchingSnippet = function(snippetList, before, after) {
|
|
428
|
+
SnippetManager.prototype.findMatchingSnippet = function (snippetList, before, after) {
|
|
555
429
|
for (var i = snippetList.length; i--;) {
|
|
556
430
|
var s = snippetList[i];
|
|
557
431
|
if (s.startRe && !s.startRe.test(before))
|
|
@@ -560,7 +434,6 @@ var SnippetManager = function() {
|
|
|
560
434
|
continue;
|
|
561
435
|
if (!s.startRe && !s.endRe)
|
|
562
436
|
continue;
|
|
563
|
-
|
|
564
437
|
s.matchBefore = s.startRe ? s.startRe.exec(before) : [""];
|
|
565
438
|
s.matchAfter = s.endRe ? s.endRe.exec(after) : [""];
|
|
566
439
|
s.replaceBefore = s.triggerRe ? s.triggerRe.exec(before)[0] : "";
|
|
@@ -568,21 +441,15 @@ var SnippetManager = function() {
|
|
|
568
441
|
return s;
|
|
569
442
|
}
|
|
570
443
|
};
|
|
571
|
-
|
|
572
|
-
this.snippetMap = {};
|
|
573
|
-
this.snippetNameMap = {};
|
|
574
|
-
this.register = function(snippets, scope) {
|
|
444
|
+
SnippetManager.prototype.register = function (snippets, scope) {
|
|
575
445
|
var snippetMap = this.snippetMap;
|
|
576
446
|
var snippetNameMap = this.snippetNameMap;
|
|
577
447
|
var self = this;
|
|
578
|
-
|
|
579
|
-
if (!snippets)
|
|
448
|
+
if (!snippets)
|
|
580
449
|
snippets = [];
|
|
581
|
-
|
|
582
450
|
function wrapRegexp(src) {
|
|
583
451
|
if (src && !/^\^?\(.*\)\$?$|^\\b$/.test(src))
|
|
584
452
|
src = "(?:" + src + ")";
|
|
585
|
-
|
|
586
453
|
return src || "";
|
|
587
454
|
}
|
|
588
455
|
function guardedRegexp(re, guard, opening) {
|
|
@@ -592,14 +459,14 @@ var SnippetManager = function() {
|
|
|
592
459
|
re = guard + re;
|
|
593
460
|
if (re && re[re.length - 1] != "$")
|
|
594
461
|
re = re + "$";
|
|
595
|
-
}
|
|
462
|
+
}
|
|
463
|
+
else {
|
|
596
464
|
re = re + guard;
|
|
597
465
|
if (re && re[0] != "^")
|
|
598
466
|
re = "^" + re;
|
|
599
467
|
}
|
|
600
468
|
return new RegExp(re);
|
|
601
469
|
}
|
|
602
|
-
|
|
603
470
|
function addSnippet(s) {
|
|
604
471
|
if (!s.scope)
|
|
605
472
|
s.scope = scope || "_";
|
|
@@ -608,7 +475,6 @@ var SnippetManager = function() {
|
|
|
608
475
|
snippetMap[scope] = [];
|
|
609
476
|
snippetNameMap[scope] = {};
|
|
610
477
|
}
|
|
611
|
-
|
|
612
478
|
var map = snippetNameMap[scope];
|
|
613
479
|
if (s.name) {
|
|
614
480
|
var old = map[s.name];
|
|
@@ -617,48 +483,40 @@ var SnippetManager = function() {
|
|
|
617
483
|
map[s.name] = s;
|
|
618
484
|
}
|
|
619
485
|
snippetMap[scope].push(s);
|
|
620
|
-
|
|
621
486
|
if (s.prefix)
|
|
622
487
|
s.tabTrigger = s.prefix;
|
|
623
|
-
|
|
624
488
|
if (!s.content && s.body)
|
|
625
489
|
s.content = Array.isArray(s.body) ? s.body.join("\n") : s.body;
|
|
626
|
-
|
|
627
490
|
if (s.tabTrigger && !s.trigger) {
|
|
628
491
|
if (!s.guard && /^\w/.test(s.tabTrigger))
|
|
629
492
|
s.guard = "\\b";
|
|
630
493
|
s.trigger = lang.escapeRegExp(s.tabTrigger);
|
|
631
494
|
}
|
|
632
|
-
|
|
633
495
|
if (!s.trigger && !s.guard && !s.endTrigger && !s.endGuard)
|
|
634
496
|
return;
|
|
635
|
-
|
|
636
497
|
s.startRe = guardedRegexp(s.trigger, s.guard, true);
|
|
637
498
|
s.triggerRe = new RegExp(s.trigger);
|
|
638
|
-
|
|
639
499
|
s.endRe = guardedRegexp(s.endTrigger, s.endGuard, true);
|
|
640
500
|
s.endTriggerRe = new RegExp(s.endTrigger);
|
|
641
501
|
}
|
|
642
|
-
|
|
643
502
|
if (Array.isArray(snippets)) {
|
|
644
503
|
snippets.forEach(addSnippet);
|
|
645
|
-
}
|
|
646
|
-
|
|
504
|
+
}
|
|
505
|
+
else {
|
|
506
|
+
Object.keys(snippets).forEach(function (key) {
|
|
647
507
|
addSnippet(snippets[key]);
|
|
648
508
|
});
|
|
649
509
|
}
|
|
650
|
-
|
|
651
|
-
this._signal("registerSnippets", {scope: scope});
|
|
510
|
+
this._signal("registerSnippets", { scope: scope });
|
|
652
511
|
};
|
|
653
|
-
|
|
512
|
+
SnippetManager.prototype.unregister = function (snippets, scope) {
|
|
654
513
|
var snippetMap = this.snippetMap;
|
|
655
514
|
var snippetNameMap = this.snippetNameMap;
|
|
656
|
-
|
|
657
515
|
function removeSnippet(s) {
|
|
658
|
-
var nameMap = snippetNameMap[s.scope||scope];
|
|
516
|
+
var nameMap = snippetNameMap[s.scope || scope];
|
|
659
517
|
if (nameMap && nameMap[s.name]) {
|
|
660
518
|
delete nameMap[s.name];
|
|
661
|
-
var map = snippetMap[s.scope||scope];
|
|
519
|
+
var map = snippetMap[s.scope || scope];
|
|
662
520
|
var i = map && map.indexOf(s);
|
|
663
521
|
if (i >= 0)
|
|
664
522
|
map.splice(i, 1);
|
|
@@ -669,7 +527,7 @@ var SnippetManager = function() {
|
|
|
669
527
|
else if (Array.isArray(snippets))
|
|
670
528
|
snippets.forEach(removeSnippet);
|
|
671
529
|
};
|
|
672
|
-
|
|
530
|
+
SnippetManager.prototype.parseSnippetFile = function (str) {
|
|
673
531
|
str = str.replace(/\r/g, "");
|
|
674
532
|
var list = [], snippet = {};
|
|
675
533
|
var re = /^#.*|^({[\s\S]*})\s*$|^(\S+) (.*)$|^((?:\n*\t.*)+)/gm;
|
|
@@ -679,12 +537,15 @@ var SnippetManager = function() {
|
|
|
679
537
|
try {
|
|
680
538
|
snippet = JSON.parse(m[1]);
|
|
681
539
|
list.push(snippet);
|
|
682
|
-
}
|
|
683
|
-
|
|
540
|
+
}
|
|
541
|
+
catch (e) { }
|
|
542
|
+
}
|
|
543
|
+
if (m[4]) {
|
|
684
544
|
snippet.content = m[4].replace(/^\t/gm, "");
|
|
685
545
|
list.push(snippet);
|
|
686
546
|
snippet = {};
|
|
687
|
-
}
|
|
547
|
+
}
|
|
548
|
+
else {
|
|
688
549
|
var key = m[2], val = m[3];
|
|
689
550
|
if (key == "regex") {
|
|
690
551
|
var guardRe = /\/((?:[^\/\\]|\\.)*)|$/g;
|
|
@@ -692,21 +553,23 @@ var SnippetManager = function() {
|
|
|
692
553
|
snippet.trigger = guardRe.exec(val)[1];
|
|
693
554
|
snippet.endTrigger = guardRe.exec(val)[1];
|
|
694
555
|
snippet.endGuard = guardRe.exec(val)[1];
|
|
695
|
-
}
|
|
556
|
+
}
|
|
557
|
+
else if (key == "snippet") {
|
|
696
558
|
snippet.tabTrigger = val.match(/^\S*/)[0];
|
|
697
559
|
if (!snippet.name)
|
|
698
560
|
snippet.name = val;
|
|
699
|
-
}
|
|
561
|
+
}
|
|
562
|
+
else if (key) {
|
|
700
563
|
snippet[key] = val;
|
|
701
564
|
}
|
|
702
565
|
}
|
|
703
566
|
}
|
|
704
567
|
return list;
|
|
705
568
|
};
|
|
706
|
-
|
|
569
|
+
SnippetManager.prototype.getSnippetByName = function (name, editor) {
|
|
707
570
|
var snippetMap = this.snippetNameMap;
|
|
708
571
|
var snippet;
|
|
709
|
-
this.getActiveScopes(editor).some(function(scope) {
|
|
572
|
+
this.getActiveScopes(editor).some(function (scope) {
|
|
710
573
|
var snippets = snippetMap[scope];
|
|
711
574
|
if (snippets)
|
|
712
575
|
snippet = snippets[name];
|
|
@@ -714,59 +577,172 @@ var SnippetManager = function() {
|
|
|
714
577
|
}, this);
|
|
715
578
|
return snippet;
|
|
716
579
|
};
|
|
717
|
-
|
|
718
|
-
}
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
this.
|
|
580
|
+
return SnippetManager;
|
|
581
|
+
}());
|
|
582
|
+
oop.implement(SnippetManager.prototype, EventEmitter);
|
|
583
|
+
var processSnippetText = function (editor, snippetText, options) {
|
|
584
|
+
if (options === void 0) { options = {}; }
|
|
585
|
+
var cursor = editor.getCursorPosition();
|
|
586
|
+
var line = editor.session.getLine(cursor.row);
|
|
587
|
+
var tabString = editor.session.getTabString();
|
|
588
|
+
var indentString = line.match(/^\s*/)[0];
|
|
589
|
+
if (cursor.column < indentString.length)
|
|
590
|
+
indentString = indentString.slice(0, cursor.column);
|
|
591
|
+
snippetText = snippetText.replace(/\r/g, "");
|
|
592
|
+
var tokens = this.tokenizeTmSnippet(snippetText);
|
|
593
|
+
tokens = this.resolveVariables(tokens, editor);
|
|
594
|
+
tokens = tokens.map(function (x) {
|
|
595
|
+
if (x == "\n" && !options.excludeExtraIndent)
|
|
596
|
+
return x + indentString;
|
|
597
|
+
if (typeof x == "string")
|
|
598
|
+
return x.replace(/\t/g, tabString);
|
|
599
|
+
return x;
|
|
600
|
+
});
|
|
601
|
+
var tabstops = [];
|
|
602
|
+
tokens.forEach(function (p, i) {
|
|
603
|
+
if (typeof p != "object")
|
|
604
|
+
return;
|
|
605
|
+
var id = p.tabstopId;
|
|
606
|
+
var ts = tabstops[id];
|
|
607
|
+
if (!ts) {
|
|
608
|
+
ts = tabstops[id] = [];
|
|
609
|
+
ts.index = id;
|
|
610
|
+
ts.value = "";
|
|
611
|
+
ts.parents = {};
|
|
612
|
+
}
|
|
613
|
+
if (ts.indexOf(p) !== -1)
|
|
614
|
+
return;
|
|
615
|
+
if (p.choices && !ts.choices)
|
|
616
|
+
ts.choices = p.choices;
|
|
617
|
+
ts.push(p);
|
|
618
|
+
var i1 = tokens.indexOf(p, i + 1);
|
|
619
|
+
if (i1 === -1)
|
|
620
|
+
return;
|
|
621
|
+
var value = tokens.slice(i + 1, i1);
|
|
622
|
+
var isNested = value.some(function (t) { return typeof t === "object"; });
|
|
623
|
+
if (isNested && !ts.value) {
|
|
624
|
+
ts.value = value;
|
|
625
|
+
}
|
|
626
|
+
else if (value.length && (!ts.value || typeof ts.value !== "string")) {
|
|
627
|
+
ts.value = value.join("");
|
|
628
|
+
}
|
|
629
|
+
});
|
|
630
|
+
tabstops.forEach(function (ts) { ts.length = 0; });
|
|
631
|
+
var expanding = {};
|
|
632
|
+
function copyValue(val) {
|
|
633
|
+
var copy = [];
|
|
634
|
+
for (var i = 0; i < val.length; i++) {
|
|
635
|
+
var p = val[i];
|
|
636
|
+
if (typeof p == "object") {
|
|
637
|
+
if (expanding[p.tabstopId])
|
|
638
|
+
continue;
|
|
639
|
+
var j = val.lastIndexOf(p, i - 1);
|
|
640
|
+
p = copy[j] || { tabstopId: p.tabstopId };
|
|
641
|
+
}
|
|
642
|
+
copy[i] = p;
|
|
643
|
+
}
|
|
644
|
+
return copy;
|
|
645
|
+
}
|
|
646
|
+
for (var i = 0; i < tokens.length; i++) {
|
|
647
|
+
var p = tokens[i];
|
|
648
|
+
if (typeof p != "object")
|
|
649
|
+
continue;
|
|
650
|
+
var id = p.tabstopId;
|
|
651
|
+
var ts = tabstops[id];
|
|
652
|
+
var i1 = tokens.indexOf(p, i + 1);
|
|
653
|
+
if (expanding[id]) {
|
|
654
|
+
if (expanding[id] === p) {
|
|
655
|
+
delete expanding[id];
|
|
656
|
+
Object.keys(expanding).forEach(function (parentId) {
|
|
657
|
+
ts.parents[parentId] = true;
|
|
658
|
+
});
|
|
659
|
+
}
|
|
660
|
+
continue;
|
|
661
|
+
}
|
|
662
|
+
expanding[id] = p;
|
|
663
|
+
var value = ts.value;
|
|
664
|
+
if (typeof value !== "string")
|
|
665
|
+
value = copyValue(value);
|
|
666
|
+
else if (p.fmt)
|
|
667
|
+
value = this.tmStrFormat(value, p, editor);
|
|
668
|
+
tokens.splice.apply(tokens, [i + 1, Math.max(0, i1 - i)].concat(value, p));
|
|
669
|
+
if (ts.indexOf(p) === -1)
|
|
670
|
+
ts.push(p);
|
|
671
|
+
}
|
|
672
|
+
var row = 0, column = 0;
|
|
673
|
+
var text = "";
|
|
674
|
+
tokens.forEach(function (t) {
|
|
675
|
+
if (typeof t === "string") {
|
|
676
|
+
var lines = t.split("\n");
|
|
677
|
+
if (lines.length > 1) {
|
|
678
|
+
column = lines[lines.length - 1].length;
|
|
679
|
+
row += lines.length - 1;
|
|
680
|
+
}
|
|
681
|
+
else
|
|
682
|
+
column += t.length;
|
|
683
|
+
text += t;
|
|
684
|
+
}
|
|
685
|
+
else if (t) {
|
|
686
|
+
if (!t.start)
|
|
687
|
+
t.start = { row: row, column: column };
|
|
688
|
+
else
|
|
689
|
+
t.end = { row: row, column: column };
|
|
690
|
+
}
|
|
691
|
+
});
|
|
692
|
+
return {
|
|
693
|
+
text: text,
|
|
694
|
+
tabstops: tabstops,
|
|
695
|
+
tokens: tokens
|
|
696
|
+
};
|
|
730
697
|
};
|
|
731
|
-
(function() {
|
|
732
|
-
|
|
698
|
+
var TabstopManager = /** @class */ (function () {
|
|
699
|
+
function TabstopManager(editor) {
|
|
733
700
|
this.index = 0;
|
|
734
701
|
this.ranges = [];
|
|
735
702
|
this.tabstops = [];
|
|
703
|
+
if (editor.tabstopManager)
|
|
704
|
+
return editor.tabstopManager;
|
|
705
|
+
editor.tabstopManager = this;
|
|
706
|
+
this.$onChange = this.onChange.bind(this);
|
|
707
|
+
this.$onChangeSelection = lang.delayedCall(this.onChangeSelection.bind(this)).schedule;
|
|
708
|
+
this.$onChangeSession = this.onChangeSession.bind(this);
|
|
709
|
+
this.$onAfterExec = this.onAfterExec.bind(this);
|
|
710
|
+
this.attach(editor);
|
|
711
|
+
}
|
|
712
|
+
TabstopManager.prototype.attach = function (editor) {
|
|
736
713
|
this.$openTabstops = null;
|
|
737
714
|
this.selectedTabstop = null;
|
|
738
|
-
|
|
739
715
|
this.editor = editor;
|
|
716
|
+
this.session = editor.session;
|
|
740
717
|
this.editor.on("change", this.$onChange);
|
|
741
718
|
this.editor.on("changeSelection", this.$onChangeSelection);
|
|
742
719
|
this.editor.on("changeSession", this.$onChangeSession);
|
|
743
720
|
this.editor.commands.on("afterExec", this.$onAfterExec);
|
|
744
721
|
this.editor.keyBinding.addKeyboardHandler(this.keyboardHandler);
|
|
745
722
|
};
|
|
746
|
-
|
|
723
|
+
TabstopManager.prototype.detach = function () {
|
|
747
724
|
this.tabstops.forEach(this.removeTabstopMarkers, this);
|
|
748
|
-
this.ranges =
|
|
749
|
-
this.tabstops =
|
|
725
|
+
this.ranges.length = 0;
|
|
726
|
+
this.tabstops.length = 0;
|
|
750
727
|
this.selectedTabstop = null;
|
|
751
|
-
this.editor.
|
|
752
|
-
this.editor.
|
|
753
|
-
this.editor.
|
|
754
|
-
this.editor.commands.
|
|
728
|
+
this.editor.off("change", this.$onChange);
|
|
729
|
+
this.editor.off("changeSelection", this.$onChangeSelection);
|
|
730
|
+
this.editor.off("changeSession", this.$onChangeSession);
|
|
731
|
+
this.editor.commands.off("afterExec", this.$onAfterExec);
|
|
755
732
|
this.editor.keyBinding.removeKeyboardHandler(this.keyboardHandler);
|
|
756
733
|
this.editor.tabstopManager = null;
|
|
734
|
+
this.session = null;
|
|
757
735
|
this.editor = null;
|
|
758
736
|
};
|
|
759
|
-
|
|
760
|
-
this.onChange = function(delta) {
|
|
737
|
+
TabstopManager.prototype.onChange = function (delta) {
|
|
761
738
|
var isRemove = delta.action[0] == "r";
|
|
762
739
|
var selectedTabstop = this.selectedTabstop || {};
|
|
763
740
|
var parents = selectedTabstop.parents || {};
|
|
764
|
-
var tabstops =
|
|
741
|
+
var tabstops = this.tabstops.slice();
|
|
765
742
|
for (var i = 0; i < tabstops.length; i++) {
|
|
766
743
|
var ts = tabstops[i];
|
|
767
744
|
var active = ts == selectedTabstop || parents[ts.index];
|
|
768
745
|
ts.rangeList.$bias = active ? 0 : 1;
|
|
769
|
-
|
|
770
746
|
if (delta.action == "remove" && ts !== selectedTabstop) {
|
|
771
747
|
var parentActive = ts.parents && ts.parents[selectedTabstop.index];
|
|
772
748
|
var startIndex = ts.rangeList.pointIndex(delta.start, parentActive);
|
|
@@ -779,16 +755,16 @@ var TabstopManager = function(editor) {
|
|
|
779
755
|
}
|
|
780
756
|
ts.rangeList.$onChange(delta);
|
|
781
757
|
}
|
|
782
|
-
var session = this.
|
|
758
|
+
var session = this.session;
|
|
783
759
|
if (!this.$inChange && isRemove && session.getLength() == 1 && !session.getValue())
|
|
784
760
|
this.detach();
|
|
785
761
|
};
|
|
786
|
-
|
|
762
|
+
TabstopManager.prototype.updateLinkedFields = function () {
|
|
787
763
|
var ts = this.selectedTabstop;
|
|
788
764
|
if (!ts || !ts.hasLinkedRanges || !ts.firstNonLinked)
|
|
789
765
|
return;
|
|
790
766
|
this.$inChange = true;
|
|
791
|
-
var session = this.
|
|
767
|
+
var session = this.session;
|
|
792
768
|
var text = session.getTextRange(ts.firstNonLinked);
|
|
793
769
|
for (var i = 0; i < ts.length; i++) {
|
|
794
770
|
var range = ts[i];
|
|
@@ -800,11 +776,11 @@ var TabstopManager = function(editor) {
|
|
|
800
776
|
}
|
|
801
777
|
this.$inChange = false;
|
|
802
778
|
};
|
|
803
|
-
|
|
779
|
+
TabstopManager.prototype.onAfterExec = function (e) {
|
|
804
780
|
if (e.command && !e.command.readOnly)
|
|
805
781
|
this.updateLinkedFields();
|
|
806
782
|
};
|
|
807
|
-
|
|
783
|
+
TabstopManager.prototype.onChangeSelection = function () {
|
|
808
784
|
if (!this.editor)
|
|
809
785
|
return;
|
|
810
786
|
var lead = this.editor.selection.lead;
|
|
@@ -820,10 +796,10 @@ var TabstopManager = function(editor) {
|
|
|
820
796
|
}
|
|
821
797
|
this.detach();
|
|
822
798
|
};
|
|
823
|
-
|
|
799
|
+
TabstopManager.prototype.onChangeSession = function () {
|
|
824
800
|
this.detach();
|
|
825
801
|
};
|
|
826
|
-
|
|
802
|
+
TabstopManager.prototype.tabNext = function (dir) {
|
|
827
803
|
var max = this.tabstops.length;
|
|
828
804
|
var index = this.index + (dir || 1);
|
|
829
805
|
index = Math.min(Math.max(index, 1), max);
|
|
@@ -833,7 +809,7 @@ var TabstopManager = function(editor) {
|
|
|
833
809
|
if (index === 0)
|
|
834
810
|
this.detach();
|
|
835
811
|
};
|
|
836
|
-
|
|
812
|
+
TabstopManager.prototype.selectTabstop = function (index) {
|
|
837
813
|
this.$openTabstops = null;
|
|
838
814
|
var ts = this.tabstops[this.index];
|
|
839
815
|
if (ts)
|
|
@@ -842,10 +818,10 @@ var TabstopManager = function(editor) {
|
|
|
842
818
|
ts = this.tabstops[this.index];
|
|
843
819
|
if (!ts || !ts.length)
|
|
844
820
|
return;
|
|
845
|
-
|
|
846
821
|
this.selectedTabstop = ts;
|
|
847
822
|
var range = ts.firstNonLinked || ts;
|
|
848
|
-
if (ts.choices)
|
|
823
|
+
if (ts.choices)
|
|
824
|
+
range.cursor = range.start;
|
|
849
825
|
if (!this.editor.inVirtualSelectionMode) {
|
|
850
826
|
var sel = this.editor.multiSelect;
|
|
851
827
|
sel.toSingleRange(range);
|
|
@@ -854,17 +830,16 @@ var TabstopManager = function(editor) {
|
|
|
854
830
|
continue;
|
|
855
831
|
sel.addRange(ts[i].clone(), true);
|
|
856
832
|
}
|
|
857
|
-
}
|
|
833
|
+
}
|
|
834
|
+
else {
|
|
858
835
|
this.editor.selection.fromOrientedRange(range);
|
|
859
836
|
}
|
|
860
|
-
|
|
861
837
|
this.editor.keyBinding.addKeyboardHandler(this.keyboardHandler);
|
|
862
838
|
if (this.selectedTabstop && this.selectedTabstop.choices)
|
|
863
|
-
this.editor.execCommand("startAutocomplete", {matches: this.selectedTabstop.choices});
|
|
839
|
+
this.editor.execCommand("startAutocomplete", { matches: this.selectedTabstop.choices });
|
|
864
840
|
};
|
|
865
|
-
|
|
841
|
+
TabstopManager.prototype.addTabstops = function (tabstops, start, end) {
|
|
866
842
|
var useLink = this.useLink || !this.editor.getOption("enableMultiselect");
|
|
867
|
-
|
|
868
843
|
if (!this.$openTabstops)
|
|
869
844
|
this.$openTabstops = [];
|
|
870
845
|
if (!tabstops[0]) {
|
|
@@ -874,13 +849,11 @@ var TabstopManager = function(editor) {
|
|
|
874
849
|
tabstops[0] = [p];
|
|
875
850
|
tabstops[0].index = 0;
|
|
876
851
|
}
|
|
877
|
-
|
|
878
852
|
var i = this.index;
|
|
879
853
|
var arg = [i + 1, 0];
|
|
880
854
|
var ranges = this.ranges;
|
|
881
|
-
tabstops.forEach(function(ts, index) {
|
|
855
|
+
tabstops.forEach(function (ts, index) {
|
|
882
856
|
var dest = this.$openTabstops[index] || ts;
|
|
883
|
-
|
|
884
857
|
for (var i = 0; i < ts.length; i++) {
|
|
885
858
|
var p = ts[i];
|
|
886
859
|
var range = Range.fromPoints(p.start, p.end || p.start);
|
|
@@ -896,7 +869,8 @@ var TabstopManager = function(editor) {
|
|
|
896
869
|
if (p.fmtString || (dest.firstNonLinked && useLink)) {
|
|
897
870
|
range.linked = true;
|
|
898
871
|
dest.hasLinkedRanges = true;
|
|
899
|
-
}
|
|
872
|
+
}
|
|
873
|
+
else if (!dest.firstNonLinked)
|
|
900
874
|
dest.firstNonLinked = range;
|
|
901
875
|
}
|
|
902
876
|
if (!dest.firstNonLinked)
|
|
@@ -910,36 +884,37 @@ var TabstopManager = function(editor) {
|
|
|
910
884
|
dest.rangeList.$bias = 0;
|
|
911
885
|
dest.rangeList.addList(dest);
|
|
912
886
|
}, this);
|
|
913
|
-
|
|
914
887
|
if (arg.length > 2) {
|
|
915
888
|
if (this.tabstops.length)
|
|
916
889
|
arg.push(arg.splice(2, 1)[0]);
|
|
917
890
|
this.tabstops.splice.apply(this.tabstops, arg);
|
|
918
891
|
}
|
|
919
892
|
};
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
if (!range.markerId)
|
|
893
|
+
TabstopManager.prototype.addTabstopMarkers = function (ts) {
|
|
894
|
+
var session = this.session;
|
|
895
|
+
ts.forEach(function (range) {
|
|
896
|
+
if (!range.markerId)
|
|
925
897
|
range.markerId = session.addMarker(range, "ace_snippet-marker", "text");
|
|
926
898
|
});
|
|
927
899
|
};
|
|
928
|
-
|
|
929
|
-
var session = this.
|
|
930
|
-
ts.forEach(function(range) {
|
|
900
|
+
TabstopManager.prototype.removeTabstopMarkers = function (ts) {
|
|
901
|
+
var session = this.session;
|
|
902
|
+
ts.forEach(function (range) {
|
|
931
903
|
session.removeMarker(range.markerId);
|
|
932
904
|
range.markerId = null;
|
|
933
905
|
});
|
|
934
906
|
};
|
|
935
|
-
|
|
907
|
+
TabstopManager.prototype.removeRange = function (range) {
|
|
936
908
|
var i = range.tabstop.indexOf(range);
|
|
937
|
-
if (i != -1)
|
|
909
|
+
if (i != -1)
|
|
910
|
+
range.tabstop.splice(i, 1);
|
|
938
911
|
i = this.ranges.indexOf(range);
|
|
939
|
-
if (i != -1)
|
|
912
|
+
if (i != -1)
|
|
913
|
+
this.ranges.splice(i, 1);
|
|
940
914
|
i = range.tabstop.rangeList.ranges.indexOf(range);
|
|
941
|
-
if (i != -1)
|
|
942
|
-
|
|
915
|
+
if (i != -1)
|
|
916
|
+
range.tabstop.splice(i, 1);
|
|
917
|
+
this.session.removeMarker(range.markerId);
|
|
943
918
|
if (!range.tabstop.length) {
|
|
944
919
|
i = this.tabstops.indexOf(range.tabstop);
|
|
945
920
|
if (i != -1)
|
|
@@ -948,428 +923,522 @@ var TabstopManager = function(editor) {
|
|
|
948
923
|
this.detach();
|
|
949
924
|
}
|
|
950
925
|
};
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
}
|
|
968
|
-
})
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
var movePoint = function(point, diff) {
|
|
926
|
+
return TabstopManager;
|
|
927
|
+
}());
|
|
928
|
+
TabstopManager.prototype.keyboardHandler = new HashHandler();
|
|
929
|
+
TabstopManager.prototype.keyboardHandler.bindKeys({
|
|
930
|
+
"Tab": function (editor) {
|
|
931
|
+
if (exports.snippetManager && exports.snippetManager.expandWithTab(editor))
|
|
932
|
+
return;
|
|
933
|
+
editor.tabstopManager.tabNext(1);
|
|
934
|
+
editor.renderer.scrollCursorIntoView();
|
|
935
|
+
},
|
|
936
|
+
"Shift-Tab": function (editor) {
|
|
937
|
+
editor.tabstopManager.tabNext(-1);
|
|
938
|
+
editor.renderer.scrollCursorIntoView();
|
|
939
|
+
},
|
|
940
|
+
"Esc": function (editor) {
|
|
941
|
+
editor.tabstopManager.detach();
|
|
942
|
+
}
|
|
943
|
+
});
|
|
944
|
+
var movePoint = function (point, diff) {
|
|
973
945
|
if (point.row == 0)
|
|
974
946
|
point.column += diff.column;
|
|
975
947
|
point.row += diff.row;
|
|
976
948
|
};
|
|
977
|
-
|
|
978
|
-
var moveRelative = function(point, start) {
|
|
949
|
+
var moveRelative = function (point, start) {
|
|
979
950
|
if (point.row == start.row)
|
|
980
951
|
point.column -= start.column;
|
|
981
952
|
point.row -= start.row;
|
|
982
953
|
};
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
dom.importCssString("\
|
|
986
|
-
.ace_snippet-marker {\
|
|
987
|
-
-moz-box-sizing: border-box;\
|
|
988
|
-
box-sizing: border-box;\
|
|
989
|
-
background: rgba(194, 193, 208, 0.09);\
|
|
990
|
-
border: 1px dotted rgba(211, 208, 235, 0.62);\
|
|
991
|
-
position: absolute;\
|
|
992
|
-
}", "snippets.css", false);
|
|
993
|
-
|
|
954
|
+
dom.importCssString("\n.ace_snippet-marker {\n -moz-box-sizing: border-box;\n box-sizing: border-box;\n background: rgba(194, 193, 208, 0.09);\n border: 1px dotted rgba(211, 208, 235, 0.62);\n position: absolute;\n}", "snippets.css", false);
|
|
994
955
|
exports.snippetManager = new SnippetManager();
|
|
995
|
-
|
|
996
|
-
|
|
997
956
|
var Editor = require("./editor").Editor;
|
|
998
|
-
(function() {
|
|
999
|
-
this.insertSnippet = function(content, options) {
|
|
957
|
+
(function () {
|
|
958
|
+
this.insertSnippet = function (content, options) {
|
|
1000
959
|
return exports.snippetManager.insertSnippet(this, content, options);
|
|
1001
960
|
};
|
|
1002
|
-
this.expandSnippet = function(options) {
|
|
961
|
+
this.expandSnippet = function (options) {
|
|
1003
962
|
return exports.snippetManager.expandWithTab(this, options);
|
|
1004
963
|
};
|
|
1005
964
|
}).call(Editor.prototype);
|
|
1006
965
|
|
|
1007
966
|
});
|
|
1008
967
|
|
|
1009
|
-
ace.define("ace/autocomplete/popup",[], function(require, exports, module)
|
|
1010
|
-
"use strict";
|
|
1011
|
-
|
|
968
|
+
ace.define("ace/autocomplete/popup",["require","exports","module","ace/virtual_renderer","ace/editor","ace/range","ace/lib/event","ace/lib/lang","ace/lib/dom","ace/config"], function(require, exports, module){"use strict";
|
|
1012
969
|
var Renderer = require("../virtual_renderer").VirtualRenderer;
|
|
1013
970
|
var Editor = require("../editor").Editor;
|
|
1014
971
|
var Range = require("../range").Range;
|
|
1015
972
|
var event = require("../lib/event");
|
|
1016
973
|
var lang = require("../lib/lang");
|
|
1017
974
|
var dom = require("../lib/dom");
|
|
1018
|
-
|
|
1019
|
-
var
|
|
975
|
+
var nls = require("../config").nls;
|
|
976
|
+
var getAriaId = function (index) {
|
|
977
|
+
return "suggest-aria-id:".concat(index);
|
|
978
|
+
};
|
|
979
|
+
var $singleLineEditor = function (el) {
|
|
1020
980
|
var renderer = new Renderer(el);
|
|
1021
|
-
|
|
1022
981
|
renderer.$maxLines = 4;
|
|
1023
|
-
|
|
1024
982
|
var editor = new Editor(renderer);
|
|
1025
|
-
|
|
1026
983
|
editor.setHighlightActiveLine(false);
|
|
1027
984
|
editor.setShowPrintMargin(false);
|
|
1028
985
|
editor.renderer.setShowGutter(false);
|
|
1029
986
|
editor.renderer.setHighlightGutterLine(false);
|
|
1030
|
-
|
|
1031
987
|
editor.$mouseHandler.$focusTimeout = 0;
|
|
1032
988
|
editor.$highlightTagPending = true;
|
|
1033
|
-
|
|
1034
989
|
return editor;
|
|
1035
990
|
};
|
|
991
|
+
var AcePopup = /** @class */ (function () {
|
|
992
|
+
function AcePopup(parentNode) {
|
|
993
|
+
var el = dom.createElement("div");
|
|
994
|
+
var popup = new $singleLineEditor(el);
|
|
995
|
+
if (parentNode) {
|
|
996
|
+
parentNode.appendChild(el);
|
|
997
|
+
}
|
|
998
|
+
el.style.display = "none";
|
|
999
|
+
popup.renderer.content.style.cursor = "default";
|
|
1000
|
+
popup.renderer.setStyle("ace_autocomplete");
|
|
1001
|
+
popup.renderer.$textLayer.element.setAttribute("role", "listbox");
|
|
1002
|
+
popup.renderer.$textLayer.element.setAttribute("aria-label", nls("Autocomplete suggestions"));
|
|
1003
|
+
popup.renderer.textarea.setAttribute("aria-hidden", "true");
|
|
1004
|
+
popup.setOption("displayIndentGuides", false);
|
|
1005
|
+
popup.setOption("dragDelay", 150);
|
|
1006
|
+
var noop = function () { };
|
|
1007
|
+
popup.focus = noop;
|
|
1008
|
+
popup.$isFocused = true;
|
|
1009
|
+
popup.renderer.$cursorLayer.restartTimer = noop;
|
|
1010
|
+
popup.renderer.$cursorLayer.element.style.opacity = 0;
|
|
1011
|
+
popup.renderer.$maxLines = 8;
|
|
1012
|
+
popup.renderer.$keepTextAreaAtCursor = false;
|
|
1013
|
+
popup.setHighlightActiveLine(false);
|
|
1014
|
+
popup.session.highlight("");
|
|
1015
|
+
popup.session.$searchHighlight.clazz = "ace_highlight-marker";
|
|
1016
|
+
popup.on("mousedown", function (e) {
|
|
1017
|
+
var pos = e.getDocumentPosition();
|
|
1018
|
+
popup.selection.moveToPosition(pos);
|
|
1019
|
+
selectionMarker.start.row = selectionMarker.end.row = pos.row;
|
|
1020
|
+
e.stop();
|
|
1021
|
+
});
|
|
1022
|
+
var lastMouseEvent;
|
|
1023
|
+
var hoverMarker = new Range(-1, 0, -1, Infinity);
|
|
1024
|
+
var selectionMarker = new Range(-1, 0, -1, Infinity);
|
|
1025
|
+
selectionMarker.id = popup.session.addMarker(selectionMarker, "ace_active-line", "fullLine");
|
|
1026
|
+
popup.setSelectOnHover = function (val) {
|
|
1027
|
+
if (!val) {
|
|
1028
|
+
hoverMarker.id = popup.session.addMarker(hoverMarker, "ace_line-hover", "fullLine");
|
|
1029
|
+
}
|
|
1030
|
+
else if (hoverMarker.id) {
|
|
1031
|
+
popup.session.removeMarker(hoverMarker.id);
|
|
1032
|
+
hoverMarker.id = null;
|
|
1033
|
+
}
|
|
1034
|
+
};
|
|
1035
|
+
popup.setSelectOnHover(false);
|
|
1036
|
+
popup.on("mousemove", function (e) {
|
|
1037
|
+
if (!lastMouseEvent) {
|
|
1038
|
+
lastMouseEvent = e;
|
|
1039
|
+
return;
|
|
1040
|
+
}
|
|
1041
|
+
if (lastMouseEvent.x == e.x && lastMouseEvent.y == e.y) {
|
|
1042
|
+
return;
|
|
1043
|
+
}
|
|
1044
|
+
lastMouseEvent = e;
|
|
1045
|
+
lastMouseEvent.scrollTop = popup.renderer.scrollTop;
|
|
1046
|
+
popup.isMouseOver = true;
|
|
1047
|
+
var row = lastMouseEvent.getDocumentPosition().row;
|
|
1048
|
+
if (hoverMarker.start.row != row) {
|
|
1049
|
+
if (!hoverMarker.id)
|
|
1050
|
+
popup.setRow(row);
|
|
1051
|
+
setHoverMarker(row);
|
|
1052
|
+
}
|
|
1053
|
+
});
|
|
1054
|
+
popup.renderer.on("beforeRender", function () {
|
|
1055
|
+
if (lastMouseEvent && hoverMarker.start.row != -1) {
|
|
1056
|
+
lastMouseEvent.$pos = null;
|
|
1057
|
+
var row = lastMouseEvent.getDocumentPosition().row;
|
|
1058
|
+
if (!hoverMarker.id)
|
|
1059
|
+
popup.setRow(row);
|
|
1060
|
+
setHoverMarker(row, true);
|
|
1061
|
+
}
|
|
1062
|
+
});
|
|
1063
|
+
popup.renderer.on("afterRender", function () {
|
|
1064
|
+
var row = popup.getRow();
|
|
1065
|
+
var t = popup.renderer.$textLayer;
|
|
1066
|
+
var selected = t.element.childNodes[row - t.config.firstRow];
|
|
1067
|
+
var el = document.activeElement; // Active element is textarea of main editor
|
|
1068
|
+
if (selected !== t.selectedNode && t.selectedNode) {
|
|
1069
|
+
dom.removeCssClass(t.selectedNode, "ace_selected");
|
|
1070
|
+
el.removeAttribute("aria-activedescendant");
|
|
1071
|
+
t.selectedNode.removeAttribute("id");
|
|
1072
|
+
}
|
|
1073
|
+
t.selectedNode = selected;
|
|
1074
|
+
if (selected) {
|
|
1075
|
+
dom.addCssClass(selected, "ace_selected");
|
|
1076
|
+
var ariaId = getAriaId(row);
|
|
1077
|
+
selected.id = ariaId;
|
|
1078
|
+
t.element.setAttribute("aria-activedescendant", ariaId);
|
|
1079
|
+
el.setAttribute("aria-activedescendant", ariaId);
|
|
1080
|
+
selected.setAttribute("role", "option");
|
|
1081
|
+
selected.setAttribute("aria-label", popup.getData(row).value);
|
|
1082
|
+
selected.setAttribute("aria-setsize", popup.data.length);
|
|
1083
|
+
selected.setAttribute("aria-posinset", row + 1);
|
|
1084
|
+
selected.setAttribute("aria-describedby", "doc-tooltip");
|
|
1085
|
+
}
|
|
1086
|
+
});
|
|
1087
|
+
var hideHoverMarker = function () { setHoverMarker(-1); };
|
|
1088
|
+
var setHoverMarker = function (row, suppressRedraw) {
|
|
1089
|
+
if (row !== hoverMarker.start.row) {
|
|
1090
|
+
hoverMarker.start.row = hoverMarker.end.row = row;
|
|
1091
|
+
if (!suppressRedraw)
|
|
1092
|
+
popup.session._emit("changeBackMarker");
|
|
1093
|
+
popup._emit("changeHoverMarker");
|
|
1094
|
+
}
|
|
1095
|
+
};
|
|
1096
|
+
popup.getHoveredRow = function () {
|
|
1097
|
+
return hoverMarker.start.row;
|
|
1098
|
+
};
|
|
1099
|
+
event.addListener(popup.container, "mouseout", function () {
|
|
1100
|
+
popup.isMouseOver = false;
|
|
1101
|
+
hideHoverMarker();
|
|
1102
|
+
});
|
|
1103
|
+
popup.on("hide", hideHoverMarker);
|
|
1104
|
+
popup.on("changeSelection", hideHoverMarker);
|
|
1105
|
+
popup.session.doc.getLength = function () {
|
|
1106
|
+
return popup.data.length;
|
|
1107
|
+
};
|
|
1108
|
+
popup.session.doc.getLine = function (i) {
|
|
1109
|
+
var data = popup.data[i];
|
|
1110
|
+
if (typeof data == "string")
|
|
1111
|
+
return data;
|
|
1112
|
+
return (data && data.value) || "";
|
|
1113
|
+
};
|
|
1114
|
+
var bgTokenizer = popup.session.bgTokenizer;
|
|
1115
|
+
bgTokenizer.$tokenizeRow = function (row) {
|
|
1116
|
+
var data = popup.data[row];
|
|
1117
|
+
var tokens = [];
|
|
1118
|
+
if (!data)
|
|
1119
|
+
return tokens;
|
|
1120
|
+
if (typeof data == "string")
|
|
1121
|
+
data = { value: data };
|
|
1122
|
+
var caption = data.caption || data.value || data.name;
|
|
1123
|
+
function addToken(value, className) {
|
|
1124
|
+
value && tokens.push({
|
|
1125
|
+
type: (data.className || "") + (className || ""),
|
|
1126
|
+
value: value
|
|
1127
|
+
});
|
|
1128
|
+
}
|
|
1129
|
+
var lower = caption.toLowerCase();
|
|
1130
|
+
var filterText = (popup.filterText || "").toLowerCase();
|
|
1131
|
+
var lastIndex = 0;
|
|
1132
|
+
var lastI = 0;
|
|
1133
|
+
for (var i = 0; i <= filterText.length; i++) {
|
|
1134
|
+
if (i != lastI && (data.matchMask & (1 << i) || i == filterText.length)) {
|
|
1135
|
+
var sub = filterText.slice(lastI, i);
|
|
1136
|
+
lastI = i;
|
|
1137
|
+
var index = lower.indexOf(sub, lastIndex);
|
|
1138
|
+
if (index == -1)
|
|
1139
|
+
continue;
|
|
1140
|
+
addToken(caption.slice(lastIndex, index), "");
|
|
1141
|
+
lastIndex = index + sub.length;
|
|
1142
|
+
addToken(caption.slice(index, lastIndex), "completion-highlight");
|
|
1143
|
+
}
|
|
1144
|
+
}
|
|
1145
|
+
addToken(caption.slice(lastIndex, caption.length), "");
|
|
1146
|
+
tokens.push({ type: "completion-spacer", value: " " });
|
|
1147
|
+
if (data.meta)
|
|
1148
|
+
tokens.push({ type: "completion-meta", value: data.meta });
|
|
1149
|
+
if (data.message)
|
|
1150
|
+
tokens.push({ type: "completion-message", value: data.message });
|
|
1151
|
+
return tokens;
|
|
1152
|
+
};
|
|
1153
|
+
bgTokenizer.$updateOnChange = noop;
|
|
1154
|
+
bgTokenizer.start = noop;
|
|
1155
|
+
popup.session.$computeWidth = function () {
|
|
1156
|
+
return this.screenWidth = 0;
|
|
1157
|
+
};
|
|
1158
|
+
popup.isOpen = false;
|
|
1159
|
+
popup.isTopdown = false;
|
|
1160
|
+
popup.autoSelect = true;
|
|
1161
|
+
popup.filterText = "";
|
|
1162
|
+
popup.isMouseOver = false;
|
|
1163
|
+
popup.data = [];
|
|
1164
|
+
popup.setData = function (list, filterText) {
|
|
1165
|
+
popup.filterText = filterText || "";
|
|
1166
|
+
popup.setValue(lang.stringRepeat("\n", list.length), -1);
|
|
1167
|
+
popup.data = list || [];
|
|
1168
|
+
popup.setRow(0);
|
|
1169
|
+
};
|
|
1170
|
+
popup.getData = function (row) {
|
|
1171
|
+
return popup.data[row];
|
|
1172
|
+
};
|
|
1173
|
+
popup.getRow = function () {
|
|
1174
|
+
return selectionMarker.start.row;
|
|
1175
|
+
};
|
|
1176
|
+
popup.setRow = function (line) {
|
|
1177
|
+
line = Math.max(this.autoSelect ? 0 : -1, Math.min(this.data.length - 1, line));
|
|
1178
|
+
if (selectionMarker.start.row != line) {
|
|
1179
|
+
popup.selection.clearSelection();
|
|
1180
|
+
selectionMarker.start.row = selectionMarker.end.row = line || 0;
|
|
1181
|
+
popup.session._emit("changeBackMarker");
|
|
1182
|
+
popup.moveCursorTo(line || 0, 0);
|
|
1183
|
+
if (popup.isOpen)
|
|
1184
|
+
popup._signal("select");
|
|
1185
|
+
}
|
|
1186
|
+
};
|
|
1187
|
+
popup.on("changeSelection", function () {
|
|
1188
|
+
if (popup.isOpen)
|
|
1189
|
+
popup.setRow(popup.selection.lead.row);
|
|
1190
|
+
popup.renderer.scrollCursorIntoView();
|
|
1191
|
+
});
|
|
1192
|
+
popup.hide = function () {
|
|
1193
|
+
this.container.style.display = "none";
|
|
1194
|
+
popup.anchorPos = null;
|
|
1195
|
+
popup.anchor = null;
|
|
1196
|
+
if (popup.isOpen) {
|
|
1197
|
+
popup.isOpen = false;
|
|
1198
|
+
this._signal("hide");
|
|
1199
|
+
}
|
|
1200
|
+
};
|
|
1201
|
+
popup.tryShow = function (pos, lineHeight, anchor, forceShow) {
|
|
1202
|
+
if (!forceShow && popup.isOpen && popup.anchorPos && popup.anchor &&
|
|
1203
|
+
popup.anchorPos.top === pos.top && popup.anchorPos.left === pos.left &&
|
|
1204
|
+
popup.anchor === anchor) {
|
|
1205
|
+
return true;
|
|
1206
|
+
}
|
|
1207
|
+
var el = this.container;
|
|
1208
|
+
var screenHeight = window.innerHeight;
|
|
1209
|
+
var screenWidth = window.innerWidth;
|
|
1210
|
+
var renderer = this.renderer;
|
|
1211
|
+
var maxH = renderer.$maxLines * lineHeight * 1.4;
|
|
1212
|
+
var dims = { top: 0, bottom: 0, left: 0 };
|
|
1213
|
+
var spaceBelow = screenHeight - pos.top - 3 * this.$borderSize - lineHeight;
|
|
1214
|
+
var spaceAbove = pos.top - 3 * this.$borderSize;
|
|
1215
|
+
if (!anchor) {
|
|
1216
|
+
if (spaceAbove <= spaceBelow || spaceBelow >= maxH) {
|
|
1217
|
+
anchor = "bottom";
|
|
1218
|
+
}
|
|
1219
|
+
else {
|
|
1220
|
+
anchor = "top";
|
|
1221
|
+
}
|
|
1222
|
+
}
|
|
1223
|
+
if (anchor === "top") {
|
|
1224
|
+
dims.bottom = pos.top - this.$borderSize;
|
|
1225
|
+
dims.top = dims.bottom - maxH;
|
|
1226
|
+
}
|
|
1227
|
+
else if (anchor === "bottom") {
|
|
1228
|
+
dims.top = pos.top + lineHeight + this.$borderSize;
|
|
1229
|
+
dims.bottom = dims.top + maxH;
|
|
1230
|
+
}
|
|
1231
|
+
var fitsX = dims.top >= 0 && dims.bottom <= screenHeight;
|
|
1232
|
+
if (!forceShow && !fitsX) {
|
|
1233
|
+
return false;
|
|
1234
|
+
}
|
|
1235
|
+
if (!fitsX) {
|
|
1236
|
+
if (anchor === "top") {
|
|
1237
|
+
renderer.$maxPixelHeight = spaceAbove;
|
|
1238
|
+
}
|
|
1239
|
+
else {
|
|
1240
|
+
renderer.$maxPixelHeight = spaceBelow;
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
else {
|
|
1244
|
+
renderer.$maxPixelHeight = null;
|
|
1245
|
+
}
|
|
1246
|
+
if (anchor === "top") {
|
|
1247
|
+
el.style.top = "";
|
|
1248
|
+
el.style.bottom = (screenHeight - dims.bottom) + "px";
|
|
1249
|
+
popup.isTopdown = false;
|
|
1250
|
+
}
|
|
1251
|
+
else {
|
|
1252
|
+
el.style.top = dims.top + "px";
|
|
1253
|
+
el.style.bottom = "";
|
|
1254
|
+
popup.isTopdown = true;
|
|
1255
|
+
}
|
|
1256
|
+
el.style.display = "";
|
|
1257
|
+
var left = pos.left;
|
|
1258
|
+
if (left + el.offsetWidth > screenWidth)
|
|
1259
|
+
left = screenWidth - el.offsetWidth;
|
|
1260
|
+
el.style.left = left + "px";
|
|
1261
|
+
el.style.right = "";
|
|
1262
|
+
if (!popup.isOpen) {
|
|
1263
|
+
popup.isOpen = true;
|
|
1264
|
+
this._signal("show");
|
|
1265
|
+
lastMouseEvent = null;
|
|
1266
|
+
}
|
|
1267
|
+
popup.anchorPos = pos;
|
|
1268
|
+
popup.anchor = anchor;
|
|
1269
|
+
return true;
|
|
1270
|
+
};
|
|
1271
|
+
popup.show = function (pos, lineHeight, topdownOnly) {
|
|
1272
|
+
this.tryShow(pos, lineHeight, topdownOnly ? "bottom" : undefined, true);
|
|
1273
|
+
};
|
|
1274
|
+
popup.goTo = function (where) {
|
|
1275
|
+
var row = this.getRow();
|
|
1276
|
+
var max = this.session.getLength() - 1;
|
|
1277
|
+
switch (where) {
|
|
1278
|
+
case "up":
|
|
1279
|
+
row = row <= 0 ? max : row - 1;
|
|
1280
|
+
break;
|
|
1281
|
+
case "down":
|
|
1282
|
+
row = row >= max ? -1 : row + 1;
|
|
1283
|
+
break;
|
|
1284
|
+
case "start":
|
|
1285
|
+
row = 0;
|
|
1286
|
+
break;
|
|
1287
|
+
case "end":
|
|
1288
|
+
row = max;
|
|
1289
|
+
break;
|
|
1290
|
+
}
|
|
1291
|
+
this.setRow(row);
|
|
1292
|
+
};
|
|
1293
|
+
popup.getTextLeftOffset = function () {
|
|
1294
|
+
return this.$borderSize + this.renderer.$padding + this.$imageSize;
|
|
1295
|
+
};
|
|
1296
|
+
popup.$imageSize = 0;
|
|
1297
|
+
popup.$borderSize = 1;
|
|
1298
|
+
return popup;
|
|
1299
|
+
}
|
|
1300
|
+
return AcePopup;
|
|
1301
|
+
}());
|
|
1302
|
+
dom.importCssString("\n.ace_editor.ace_autocomplete .ace_marker-layer .ace_active-line {\n background-color: #CAD6FA;\n z-index: 1;\n}\n.ace_dark.ace_editor.ace_autocomplete .ace_marker-layer .ace_active-line {\n background-color: #3a674e;\n}\n.ace_editor.ace_autocomplete .ace_line-hover {\n border: 1px solid #abbffe;\n margin-top: -1px;\n background: rgba(233,233,253,0.4);\n position: absolute;\n z-index: 2;\n}\n.ace_dark.ace_editor.ace_autocomplete .ace_line-hover {\n border: 1px solid rgba(109, 150, 13, 0.8);\n background: rgba(58, 103, 78, 0.62);\n}\n.ace_completion-meta {\n opacity: 0.5;\n margin-left: 0.9em;\n}\n.ace_completion-message {\n margin-left: 0.9em;\n color: blue;\n}\n.ace_editor.ace_autocomplete .ace_completion-highlight{\n color: #2d69c7;\n}\n.ace_dark.ace_editor.ace_autocomplete .ace_completion-highlight{\n color: #93ca12;\n}\n.ace_editor.ace_autocomplete {\n width: 300px;\n z-index: 200000;\n border: 1px lightgray solid;\n position: fixed;\n box-shadow: 2px 3px 5px rgba(0,0,0,.2);\n line-height: 1.4;\n background: #fefefe;\n color: #111;\n}\n.ace_dark.ace_editor.ace_autocomplete {\n border: 1px #484747 solid;\n box-shadow: 2px 3px 5px rgba(0, 0, 0, 0.51);\n line-height: 1.4;\n background: #25282c;\n color: #c1c1c1;\n}\n.ace_autocomplete .ace_text-layer {\n width: calc(100% - 8px);\n}\n.ace_autocomplete .ace_line {\n display: flex;\n align-items: center;\n}\n.ace_autocomplete .ace_line > * {\n min-width: 0;\n flex: 0 0 auto;\n}\n.ace_autocomplete .ace_line .ace_ {\n flex: 0 1 auto;\n overflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n}\n.ace_autocomplete .ace_completion-spacer {\n flex: 1;\n}\n.ace_autocomplete.ace_loading:after {\n content: \"\";\n position: absolute;\n top: 0px;\n height: 2px;\n width: 8%;\n background: blue;\n z-index: 100;\n animation: ace_progress 3s infinite linear;\n animation-delay: 300ms;\n transform: translateX(-100%) scaleX(1);\n}\n@keyframes ace_progress {\n 0% { transform: translateX(-100%) scaleX(1) }\n 50% { transform: translateX(625%) scaleX(2) } \n 100% { transform: translateX(1500%) scaleX(3) } \n}\n@media (prefers-reduced-motion) {\n .ace_autocomplete.ace_loading:after {\n transform: translateX(625%) scaleX(2);\n animation: none;\n }\n}\n", "autocompletion.css", false);
|
|
1303
|
+
exports.AcePopup = AcePopup;
|
|
1304
|
+
exports.$singleLineEditor = $singleLineEditor;
|
|
1305
|
+
exports.getAriaId = getAriaId;
|
|
1036
1306
|
|
|
1037
|
-
|
|
1038
|
-
var el = dom.createElement("div");
|
|
1039
|
-
var popup = new $singleLineEditor(el);
|
|
1040
|
-
|
|
1041
|
-
if (parentNode)
|
|
1042
|
-
parentNode.appendChild(el);
|
|
1043
|
-
el.style.display = "none";
|
|
1044
|
-
popup.renderer.content.style.cursor = "default";
|
|
1045
|
-
popup.renderer.setStyle("ace_autocomplete");
|
|
1046
|
-
|
|
1047
|
-
popup.setOption("displayIndentGuides", false);
|
|
1048
|
-
popup.setOption("dragDelay", 150);
|
|
1049
|
-
|
|
1050
|
-
var noop = function(){};
|
|
1051
|
-
|
|
1052
|
-
popup.focus = noop;
|
|
1053
|
-
popup.$isFocused = true;
|
|
1054
|
-
|
|
1055
|
-
popup.renderer.$cursorLayer.restartTimer = noop;
|
|
1056
|
-
popup.renderer.$cursorLayer.element.style.opacity = 0;
|
|
1057
|
-
|
|
1058
|
-
popup.renderer.$maxLines = 8;
|
|
1059
|
-
popup.renderer.$keepTextAreaAtCursor = false;
|
|
1307
|
+
});
|
|
1060
1308
|
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1309
|
+
ace.define("ace/autocomplete/inline_screenreader",["require","exports","module"], function(require, exports, module){"use strict";
|
|
1310
|
+
var AceInlineScreenReader = /** @class */ (function () {
|
|
1311
|
+
function AceInlineScreenReader(editor) {
|
|
1312
|
+
this.editor = editor;
|
|
1313
|
+
this.screenReaderDiv = document.createElement("div");
|
|
1314
|
+
this.screenReaderDiv.classList.add("ace_screenreader-only");
|
|
1315
|
+
this.editor.container.appendChild(this.screenReaderDiv);
|
|
1316
|
+
}
|
|
1317
|
+
AceInlineScreenReader.prototype.setScreenReaderContent = function (content) {
|
|
1318
|
+
if (!this.popup && this.editor.completer && this.editor.completer.popup) {
|
|
1319
|
+
this.popup = this.editor.completer.popup;
|
|
1320
|
+
this.popup.renderer.on("afterRender", function () {
|
|
1321
|
+
var row = this.popup.getRow();
|
|
1322
|
+
var t = this.popup.renderer.$textLayer;
|
|
1323
|
+
var selected = t.element.childNodes[row - t.config.firstRow];
|
|
1324
|
+
if (selected) {
|
|
1325
|
+
var idString = "doc-tooltip ";
|
|
1326
|
+
for (var lineIndex = 0; lineIndex < this._lines.length; lineIndex++) {
|
|
1327
|
+
idString += "ace-inline-screenreader-line-".concat(lineIndex, " ");
|
|
1328
|
+
}
|
|
1329
|
+
selected.setAttribute("aria-describedby", idString);
|
|
1330
|
+
}
|
|
1331
|
+
}.bind(this));
|
|
1332
|
+
}
|
|
1333
|
+
while (this.screenReaderDiv.firstChild) {
|
|
1334
|
+
this.screenReaderDiv.removeChild(this.screenReaderDiv.firstChild);
|
|
1335
|
+
}
|
|
1336
|
+
this._lines = content.split(/\r\n|\r|\n/);
|
|
1337
|
+
var codeElement = this.createCodeBlock();
|
|
1338
|
+
this.screenReaderDiv.appendChild(codeElement);
|
|
1339
|
+
};
|
|
1340
|
+
AceInlineScreenReader.prototype.destroy = function () {
|
|
1341
|
+
this.screenReaderDiv.remove();
|
|
1342
|
+
};
|
|
1343
|
+
AceInlineScreenReader.prototype.createCodeBlock = function () {
|
|
1344
|
+
var container = document.createElement("pre");
|
|
1345
|
+
container.setAttribute("id", "ace-inline-screenreader");
|
|
1346
|
+
for (var lineIndex = 0; lineIndex < this._lines.length; lineIndex++) {
|
|
1347
|
+
var codeElement = document.createElement("code");
|
|
1348
|
+
codeElement.setAttribute("id", "ace-inline-screenreader-line-".concat(lineIndex));
|
|
1349
|
+
var line = document.createTextNode(this._lines[lineIndex]);
|
|
1350
|
+
codeElement.appendChild(line);
|
|
1351
|
+
container.appendChild(codeElement);
|
|
1352
|
+
}
|
|
1353
|
+
return container;
|
|
1354
|
+
};
|
|
1355
|
+
return AceInlineScreenReader;
|
|
1356
|
+
}());
|
|
1357
|
+
exports.AceInlineScreenReader = AceInlineScreenReader;
|
|
1064
1358
|
|
|
1065
|
-
|
|
1066
|
-
var pos = e.getDocumentPosition();
|
|
1067
|
-
popup.selection.moveToPosition(pos);
|
|
1068
|
-
selectionMarker.start.row = selectionMarker.end.row = pos.row;
|
|
1069
|
-
e.stop();
|
|
1070
|
-
});
|
|
1359
|
+
});
|
|
1071
1360
|
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
popup.on("mousemove", function(e) {
|
|
1086
|
-
if (!lastMouseEvent) {
|
|
1087
|
-
lastMouseEvent = e;
|
|
1088
|
-
return;
|
|
1361
|
+
ace.define("ace/autocomplete/inline",["require","exports","module","ace/snippets","ace/autocomplete/inline_screenreader"], function(require, exports, module){"use strict";
|
|
1362
|
+
var snippetManager = require("../snippets").snippetManager;
|
|
1363
|
+
var AceInlineScreenReader = require("./inline_screenreader").AceInlineScreenReader;
|
|
1364
|
+
var AceInline = /** @class */ (function () {
|
|
1365
|
+
function AceInline() {
|
|
1366
|
+
this.editor = null;
|
|
1367
|
+
}
|
|
1368
|
+
AceInline.prototype.show = function (editor, completion, prefix) {
|
|
1369
|
+
prefix = prefix || "";
|
|
1370
|
+
if (editor && this.editor && this.editor !== editor) {
|
|
1371
|
+
this.hide();
|
|
1372
|
+
this.editor = null;
|
|
1373
|
+
this.inlineScreenReader = null;
|
|
1089
1374
|
}
|
|
1090
|
-
if (
|
|
1091
|
-
return;
|
|
1375
|
+
if (!editor || !completion) {
|
|
1376
|
+
return false;
|
|
1092
1377
|
}
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
var row = lastMouseEvent.getDocumentPosition().row;
|
|
1096
|
-
if (hoverMarker.start.row != row) {
|
|
1097
|
-
if (!hoverMarker.id)
|
|
1098
|
-
popup.setRow(row);
|
|
1099
|
-
setHoverMarker(row);
|
|
1378
|
+
if (!this.inlineScreenReader) {
|
|
1379
|
+
this.inlineScreenReader = new AceInlineScreenReader(editor);
|
|
1100
1380
|
}
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
lastMouseEvent.$pos = null;
|
|
1105
|
-
var row = lastMouseEvent.getDocumentPosition().row;
|
|
1106
|
-
if (!hoverMarker.id)
|
|
1107
|
-
popup.setRow(row);
|
|
1108
|
-
setHoverMarker(row, true);
|
|
1381
|
+
var displayText = completion.snippet ? snippetManager.getDisplayTextForSnippet(editor, completion.snippet) : completion.value;
|
|
1382
|
+
if (completion.hideInlinePreview || !displayText || !displayText.startsWith(prefix)) {
|
|
1383
|
+
return false;
|
|
1109
1384
|
}
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
if (selected !== t.selectedNode && t.selectedNode)
|
|
1116
|
-
dom.removeCssClass(t.selectedNode, "ace_selected");
|
|
1117
|
-
t.selectedNode = selected;
|
|
1118
|
-
if (selected)
|
|
1119
|
-
dom.addCssClass(selected, "ace_selected");
|
|
1120
|
-
});
|
|
1121
|
-
var hideHoverMarker = function() { setHoverMarker(-1); };
|
|
1122
|
-
var setHoverMarker = function(row, suppressRedraw) {
|
|
1123
|
-
if (row !== hoverMarker.start.row) {
|
|
1124
|
-
hoverMarker.start.row = hoverMarker.end.row = row;
|
|
1125
|
-
if (!suppressRedraw)
|
|
1126
|
-
popup.session._emit("changeBackMarker");
|
|
1127
|
-
popup._emit("changeHoverMarker");
|
|
1385
|
+
this.editor = editor;
|
|
1386
|
+
this.inlineScreenReader.setScreenReaderContent(displayText);
|
|
1387
|
+
displayText = displayText.slice(prefix.length);
|
|
1388
|
+
if (displayText === "") {
|
|
1389
|
+
editor.removeGhostText();
|
|
1128
1390
|
}
|
|
1391
|
+
else {
|
|
1392
|
+
editor.setGhostText(displayText);
|
|
1393
|
+
}
|
|
1394
|
+
return true;
|
|
1129
1395
|
};
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
popup.on("hide", hideHoverMarker);
|
|
1136
|
-
popup.on("changeSelection", hideHoverMarker);
|
|
1137
|
-
|
|
1138
|
-
popup.session.doc.getLength = function() {
|
|
1139
|
-
return popup.data.length;
|
|
1396
|
+
AceInline.prototype.isOpen = function () {
|
|
1397
|
+
if (!this.editor) {
|
|
1398
|
+
return false;
|
|
1399
|
+
}
|
|
1400
|
+
return !!this.editor.renderer.$ghostText;
|
|
1140
1401
|
};
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1402
|
+
AceInline.prototype.hide = function () {
|
|
1403
|
+
if (!this.editor) {
|
|
1404
|
+
return false;
|
|
1405
|
+
}
|
|
1406
|
+
this.editor.removeGhostText();
|
|
1407
|
+
return true;
|
|
1146
1408
|
};
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
return tokens;
|
|
1154
|
-
if (typeof data == "string")
|
|
1155
|
-
data = {value: data};
|
|
1156
|
-
var caption = data.caption || data.value || data.name;
|
|
1157
|
-
|
|
1158
|
-
function addToken(value, className) {
|
|
1159
|
-
value && tokens.push({
|
|
1160
|
-
type: (data.className || "") + (className || ""),
|
|
1161
|
-
value: value
|
|
1162
|
-
});
|
|
1409
|
+
AceInline.prototype.destroy = function () {
|
|
1410
|
+
this.hide();
|
|
1411
|
+
this.editor = null;
|
|
1412
|
+
if (this.inlineScreenReader) {
|
|
1413
|
+
this.inlineScreenReader.destroy();
|
|
1414
|
+
this.inlineScreenReader = null;
|
|
1163
1415
|
}
|
|
1164
|
-
|
|
1165
|
-
var lower = caption.toLowerCase();
|
|
1166
|
-
var filterText = (popup.filterText || "").toLowerCase();
|
|
1167
|
-
var lastIndex = 0;
|
|
1168
|
-
var lastI = 0;
|
|
1169
|
-
for (var i = 0; i <= filterText.length; i++) {
|
|
1170
|
-
if (i != lastI && (data.matchMask & (1 << i) || i == filterText.length)) {
|
|
1171
|
-
var sub = filterText.slice(lastI, i);
|
|
1172
|
-
lastI = i;
|
|
1173
|
-
var index = lower.indexOf(sub, lastIndex);
|
|
1174
|
-
if (index == -1) continue;
|
|
1175
|
-
addToken(caption.slice(lastIndex, index), "");
|
|
1176
|
-
lastIndex = index + sub.length;
|
|
1177
|
-
addToken(caption.slice(index, lastIndex), "completion-highlight");
|
|
1178
|
-
}
|
|
1179
|
-
}
|
|
1180
|
-
addToken(caption.slice(lastIndex, caption.length), "");
|
|
1181
|
-
|
|
1182
|
-
if (data.meta)
|
|
1183
|
-
tokens.push({type: "completion-meta", value: data.meta});
|
|
1184
|
-
if (data.message)
|
|
1185
|
-
tokens.push({type: "completion-message", value: data.message});
|
|
1186
|
-
|
|
1187
|
-
return tokens;
|
|
1188
1416
|
};
|
|
1189
|
-
|
|
1190
|
-
|
|
1417
|
+
return AceInline;
|
|
1418
|
+
}());
|
|
1419
|
+
exports.AceInline = AceInline;
|
|
1191
1420
|
|
|
1192
|
-
|
|
1193
|
-
return this.screenWidth = 0;
|
|
1194
|
-
};
|
|
1195
|
-
popup.isOpen = false;
|
|
1196
|
-
popup.isTopdown = false;
|
|
1197
|
-
popup.autoSelect = true;
|
|
1198
|
-
popup.filterText = "";
|
|
1421
|
+
});
|
|
1199
1422
|
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
popup.filterText = filterText || "";
|
|
1203
|
-
popup.setValue(lang.stringRepeat("\n", list.length), -1);
|
|
1204
|
-
popup.data = list || [];
|
|
1205
|
-
popup.setRow(0);
|
|
1206
|
-
};
|
|
1207
|
-
popup.getData = function(row) {
|
|
1208
|
-
return popup.data[row];
|
|
1209
|
-
};
|
|
1210
|
-
|
|
1211
|
-
popup.getRow = function() {
|
|
1212
|
-
return selectionMarker.start.row;
|
|
1213
|
-
};
|
|
1214
|
-
popup.setRow = function(line) {
|
|
1215
|
-
line = Math.max(this.autoSelect ? 0 : -1, Math.min(this.data.length, line));
|
|
1216
|
-
if (selectionMarker.start.row != line) {
|
|
1217
|
-
popup.selection.clearSelection();
|
|
1218
|
-
selectionMarker.start.row = selectionMarker.end.row = line || 0;
|
|
1219
|
-
popup.session._emit("changeBackMarker");
|
|
1220
|
-
popup.moveCursorTo(line || 0, 0);
|
|
1221
|
-
if (popup.isOpen)
|
|
1222
|
-
popup._signal("select");
|
|
1223
|
-
}
|
|
1224
|
-
};
|
|
1225
|
-
|
|
1226
|
-
popup.on("changeSelection", function() {
|
|
1227
|
-
if (popup.isOpen)
|
|
1228
|
-
popup.setRow(popup.selection.lead.row);
|
|
1229
|
-
popup.renderer.scrollCursorIntoView();
|
|
1230
|
-
});
|
|
1231
|
-
|
|
1232
|
-
popup.hide = function() {
|
|
1233
|
-
this.container.style.display = "none";
|
|
1234
|
-
this._signal("hide");
|
|
1235
|
-
popup.isOpen = false;
|
|
1236
|
-
};
|
|
1237
|
-
popup.show = function(pos, lineHeight, topdownOnly) {
|
|
1238
|
-
var el = this.container;
|
|
1239
|
-
var screenHeight = window.innerHeight;
|
|
1240
|
-
var screenWidth = window.innerWidth;
|
|
1241
|
-
var renderer = this.renderer;
|
|
1242
|
-
var maxH = renderer.$maxLines * lineHeight * 1.4;
|
|
1243
|
-
var top = pos.top + this.$borderSize;
|
|
1244
|
-
var allowTopdown = top > screenHeight / 2 && !topdownOnly;
|
|
1245
|
-
if (allowTopdown && top + lineHeight + maxH > screenHeight) {
|
|
1246
|
-
renderer.$maxPixelHeight = top - 2 * this.$borderSize;
|
|
1247
|
-
el.style.top = "";
|
|
1248
|
-
el.style.bottom = screenHeight - top + "px";
|
|
1249
|
-
popup.isTopdown = false;
|
|
1250
|
-
} else {
|
|
1251
|
-
top += lineHeight;
|
|
1252
|
-
renderer.$maxPixelHeight = screenHeight - top - 0.2 * lineHeight;
|
|
1253
|
-
el.style.top = top + "px";
|
|
1254
|
-
el.style.bottom = "";
|
|
1255
|
-
popup.isTopdown = true;
|
|
1256
|
-
}
|
|
1257
|
-
|
|
1258
|
-
el.style.display = "";
|
|
1259
|
-
|
|
1260
|
-
var left = pos.left;
|
|
1261
|
-
if (left + el.offsetWidth > screenWidth)
|
|
1262
|
-
left = screenWidth - el.offsetWidth;
|
|
1263
|
-
|
|
1264
|
-
el.style.left = left + "px";
|
|
1265
|
-
|
|
1266
|
-
this._signal("show");
|
|
1267
|
-
lastMouseEvent = null;
|
|
1268
|
-
popup.isOpen = true;
|
|
1269
|
-
};
|
|
1270
|
-
|
|
1271
|
-
popup.goTo = function(where) {
|
|
1272
|
-
var row = this.getRow();
|
|
1273
|
-
var max = this.session.getLength() - 1;
|
|
1274
|
-
|
|
1275
|
-
switch(where) {
|
|
1276
|
-
case "up": row = row <= 0 ? max : row - 1; break;
|
|
1277
|
-
case "down": row = row >= max ? -1 : row + 1; break;
|
|
1278
|
-
case "start": row = 0; break;
|
|
1279
|
-
case "end": row = max; break;
|
|
1280
|
-
}
|
|
1281
|
-
|
|
1282
|
-
this.setRow(row);
|
|
1283
|
-
};
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
popup.getTextLeftOffset = function() {
|
|
1287
|
-
return this.$borderSize + this.renderer.$padding + this.$imageSize;
|
|
1288
|
-
};
|
|
1289
|
-
|
|
1290
|
-
popup.$imageSize = 0;
|
|
1291
|
-
popup.$borderSize = 1;
|
|
1292
|
-
|
|
1293
|
-
return popup;
|
|
1294
|
-
};
|
|
1295
|
-
|
|
1296
|
-
dom.importCssString("\
|
|
1297
|
-
.ace_editor.ace_autocomplete .ace_marker-layer .ace_active-line {\
|
|
1298
|
-
background-color: #CAD6FA;\
|
|
1299
|
-
z-index: 1;\
|
|
1300
|
-
}\
|
|
1301
|
-
.ace_dark.ace_editor.ace_autocomplete .ace_marker-layer .ace_active-line {\
|
|
1302
|
-
background-color: #3a674e;\
|
|
1303
|
-
}\
|
|
1304
|
-
.ace_editor.ace_autocomplete .ace_line-hover {\
|
|
1305
|
-
border: 1px solid #abbffe;\
|
|
1306
|
-
margin-top: -1px;\
|
|
1307
|
-
background: rgba(233,233,253,0.4);\
|
|
1308
|
-
position: absolute;\
|
|
1309
|
-
z-index: 2;\
|
|
1310
|
-
}\
|
|
1311
|
-
.ace_dark.ace_editor.ace_autocomplete .ace_line-hover {\
|
|
1312
|
-
border: 1px solid rgba(109, 150, 13, 0.8);\
|
|
1313
|
-
background: rgba(58, 103, 78, 0.62);\
|
|
1314
|
-
}\
|
|
1315
|
-
.ace_completion-meta {\
|
|
1316
|
-
opacity: 0.5;\
|
|
1317
|
-
margin: 0.9em;\
|
|
1318
|
-
}\
|
|
1319
|
-
.ace_completion-message {\
|
|
1320
|
-
color: blue;\
|
|
1321
|
-
}\
|
|
1322
|
-
.ace_editor.ace_autocomplete .ace_completion-highlight{\
|
|
1323
|
-
color: #2d69c7;\
|
|
1324
|
-
}\
|
|
1325
|
-
.ace_dark.ace_editor.ace_autocomplete .ace_completion-highlight{\
|
|
1326
|
-
color: #93ca12;\
|
|
1327
|
-
}\
|
|
1328
|
-
.ace_editor.ace_autocomplete {\
|
|
1329
|
-
width: 300px;\
|
|
1330
|
-
z-index: 200000;\
|
|
1331
|
-
border: 1px lightgray solid;\
|
|
1332
|
-
position: fixed;\
|
|
1333
|
-
box-shadow: 2px 3px 5px rgba(0,0,0,.2);\
|
|
1334
|
-
line-height: 1.4;\
|
|
1335
|
-
background: #fefefe;\
|
|
1336
|
-
color: #111;\
|
|
1337
|
-
}\
|
|
1338
|
-
.ace_dark.ace_editor.ace_autocomplete {\
|
|
1339
|
-
border: 1px #484747 solid;\
|
|
1340
|
-
box-shadow: 2px 3px 5px rgba(0, 0, 0, 0.51);\
|
|
1341
|
-
line-height: 1.4;\
|
|
1342
|
-
background: #25282c;\
|
|
1343
|
-
color: #c1c1c1;\
|
|
1344
|
-
}", "autocompletion.css", false);
|
|
1345
|
-
|
|
1346
|
-
exports.AcePopup = AcePopup;
|
|
1347
|
-
exports.$singleLineEditor = $singleLineEditor;
|
|
1348
|
-
});
|
|
1349
|
-
|
|
1350
|
-
ace.define("ace/autocomplete/util",[], function(require, exports, module) {
|
|
1351
|
-
"use strict";
|
|
1352
|
-
|
|
1353
|
-
exports.parForEach = function(array, fn, callback) {
|
|
1423
|
+
ace.define("ace/autocomplete/util",["require","exports","module"], function(require, exports, module){"use strict";
|
|
1424
|
+
exports.parForEach = function (array, fn, callback) {
|
|
1354
1425
|
var completed = 0;
|
|
1355
1426
|
var arLength = array.length;
|
|
1356
1427
|
if (arLength === 0)
|
|
1357
1428
|
callback();
|
|
1358
1429
|
for (var i = 0; i < arLength; i++) {
|
|
1359
|
-
fn(array[i], function(result, err) {
|
|
1430
|
+
fn(array[i], function (result, err) {
|
|
1360
1431
|
completed++;
|
|
1361
1432
|
if (completed === arLength)
|
|
1362
1433
|
callback(result, err);
|
|
1363
1434
|
});
|
|
1364
1435
|
}
|
|
1365
1436
|
};
|
|
1366
|
-
|
|
1367
1437
|
var ID_REGEX = /[a-zA-Z_0-9\$\-\u00A2-\u2000\u2070-\uFFFF]/;
|
|
1368
|
-
|
|
1369
|
-
exports.retrievePrecedingIdentifier = function(text, pos, regex) {
|
|
1438
|
+
exports.retrievePrecedingIdentifier = function (text, pos, regex) {
|
|
1370
1439
|
regex = regex || ID_REGEX;
|
|
1371
1440
|
var buf = [];
|
|
1372
|
-
for (var i = pos-1; i >= 0; i--) {
|
|
1441
|
+
for (var i = pos - 1; i >= 0; i--) {
|
|
1373
1442
|
if (regex.test(text[i]))
|
|
1374
1443
|
buf.push(text[i]);
|
|
1375
1444
|
else
|
|
@@ -1377,8 +1446,7 @@ exports.retrievePrecedingIdentifier = function(text, pos, regex) {
|
|
|
1377
1446
|
}
|
|
1378
1447
|
return buf.reverse().join("");
|
|
1379
1448
|
};
|
|
1380
|
-
|
|
1381
|
-
exports.retrieveFollowingIdentifier = function(text, pos, regex) {
|
|
1449
|
+
exports.retrieveFollowingIdentifier = function (text, pos, regex) {
|
|
1382
1450
|
regex = regex || ID_REGEX;
|
|
1383
1451
|
var buf = [];
|
|
1384
1452
|
for (var i = pos; i < text.length; i++) {
|
|
@@ -1389,14 +1457,13 @@ exports.retrieveFollowingIdentifier = function(text, pos, regex) {
|
|
|
1389
1457
|
}
|
|
1390
1458
|
return buf;
|
|
1391
1459
|
};
|
|
1392
|
-
|
|
1393
1460
|
exports.getCompletionPrefix = function (editor) {
|
|
1394
1461
|
var pos = editor.getCursorPosition();
|
|
1395
1462
|
var line = editor.session.getLine(pos.row);
|
|
1396
1463
|
var prefix;
|
|
1397
|
-
editor.completers.forEach(function(completer) {
|
|
1464
|
+
editor.completers.forEach(function (completer) {
|
|
1398
1465
|
if (completer.identifierRegexps) {
|
|
1399
|
-
completer.identifierRegexps.forEach(function(identifierRegex) {
|
|
1466
|
+
completer.identifierRegexps.forEach(function (identifierRegex) {
|
|
1400
1467
|
if (!prefix && identifierRegex)
|
|
1401
1468
|
prefix = this.retrievePrecedingIdentifier(line, pos.column, identifierRegex);
|
|
1402
1469
|
}.bind(this));
|
|
@@ -1404,112 +1471,238 @@ exports.getCompletionPrefix = function (editor) {
|
|
|
1404
1471
|
}.bind(this));
|
|
1405
1472
|
return prefix || this.retrievePrecedingIdentifier(line, pos.column);
|
|
1406
1473
|
};
|
|
1474
|
+
exports.triggerAutocomplete = function (editor) {
|
|
1475
|
+
var pos = editor.getCursorPosition();
|
|
1476
|
+
var line = editor.session.getLine(pos.row);
|
|
1477
|
+
var column = (pos.column === 0) ? 0 : pos.column - 1;
|
|
1478
|
+
var previousChar = line[column];
|
|
1479
|
+
return editor.completers.some(function (el) {
|
|
1480
|
+
if (el.triggerCharacters && Array.isArray(el.triggerCharacters)) {
|
|
1481
|
+
return el.triggerCharacters.includes(previousChar);
|
|
1482
|
+
}
|
|
1483
|
+
});
|
|
1484
|
+
};
|
|
1407
1485
|
|
|
1408
1486
|
});
|
|
1409
1487
|
|
|
1410
|
-
ace.define("ace/autocomplete",[], function(require, exports, module)
|
|
1411
|
-
"use strict";
|
|
1412
|
-
|
|
1488
|
+
ace.define("ace/autocomplete",["require","exports","module","ace/keyboard/hash_handler","ace/autocomplete/popup","ace/autocomplete/inline","ace/autocomplete/popup","ace/autocomplete/util","ace/lib/lang","ace/lib/dom","ace/snippets","ace/config","ace/lib/event"], function(require, exports, module){"use strict";
|
|
1413
1489
|
var HashHandler = require("./keyboard/hash_handler").HashHandler;
|
|
1414
1490
|
var AcePopup = require("./autocomplete/popup").AcePopup;
|
|
1491
|
+
var AceInline = require("./autocomplete/inline").AceInline;
|
|
1492
|
+
var getAriaId = require("./autocomplete/popup").getAriaId;
|
|
1415
1493
|
var util = require("./autocomplete/util");
|
|
1416
1494
|
var lang = require("./lib/lang");
|
|
1417
1495
|
var dom = require("./lib/dom");
|
|
1418
1496
|
var snippetManager = require("./snippets").snippetManager;
|
|
1419
1497
|
var config = require("./config");
|
|
1420
|
-
|
|
1421
|
-
var
|
|
1422
|
-
|
|
1423
|
-
this.autoSelect = true;
|
|
1424
|
-
this.exactMatch = false;
|
|
1425
|
-
this.gatherCompletionsId = 0;
|
|
1426
|
-
this.keyboardHandler = new HashHandler();
|
|
1427
|
-
this.keyboardHandler.bindKeys(this.commands);
|
|
1428
|
-
|
|
1429
|
-
this.blurListener = this.blurListener.bind(this);
|
|
1430
|
-
this.changeListener = this.changeListener.bind(this);
|
|
1431
|
-
this.mousedownListener = this.mousedownListener.bind(this);
|
|
1432
|
-
this.mousewheelListener = this.mousewheelListener.bind(this);
|
|
1433
|
-
|
|
1434
|
-
this.changeTimer = lang.delayedCall(function() {
|
|
1435
|
-
this.updateCompletions(true);
|
|
1436
|
-
}.bind(this));
|
|
1437
|
-
|
|
1438
|
-
this.tooltipTimer = lang.delayedCall(this.updateDocTooltip.bind(this), 50);
|
|
1498
|
+
var event = require("./lib/event");
|
|
1499
|
+
var destroyCompleter = function (e, editor) {
|
|
1500
|
+
editor.completer && editor.completer.destroy();
|
|
1439
1501
|
};
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
this.
|
|
1445
|
-
this.
|
|
1502
|
+
var Autocomplete = /** @class */ (function () {
|
|
1503
|
+
function Autocomplete() {
|
|
1504
|
+
this.autoInsert = false;
|
|
1505
|
+
this.autoSelect = true;
|
|
1506
|
+
this.autoShown = false;
|
|
1507
|
+
this.exactMatch = false;
|
|
1508
|
+
this.inlineEnabled = false;
|
|
1509
|
+
this.keyboardHandler = new HashHandler();
|
|
1510
|
+
this.keyboardHandler.bindKeys(this.commands);
|
|
1511
|
+
this.parentNode = null;
|
|
1512
|
+
this.setSelectOnHover = false;
|
|
1513
|
+
this.stickySelectionDelay = 500;
|
|
1514
|
+
this.blurListener = this.blurListener.bind(this);
|
|
1515
|
+
this.changeListener = this.changeListener.bind(this);
|
|
1516
|
+
this.mousedownListener = this.mousedownListener.bind(this);
|
|
1517
|
+
this.mousewheelListener = this.mousewheelListener.bind(this);
|
|
1518
|
+
this.onLayoutChange = this.onLayoutChange.bind(this);
|
|
1519
|
+
this.changeTimer = lang.delayedCall(function () {
|
|
1520
|
+
this.updateCompletions(true);
|
|
1521
|
+
}.bind(this));
|
|
1522
|
+
this.tooltipTimer = lang.delayedCall(this.updateDocTooltip.bind(this), 50);
|
|
1523
|
+
this.stickySelectionTimer = lang.delayedCall(function () {
|
|
1524
|
+
this.stickySelection = true;
|
|
1525
|
+
}.bind(this), this.stickySelectionDelay);
|
|
1526
|
+
this.$firstOpenTimer = lang.delayedCall(function () {
|
|
1527
|
+
var initialPosition = this.completionProvider && this.completionProvider.initialPosition;
|
|
1528
|
+
if (this.autoShown || (this.popup && this.popup.isOpen) || !initialPosition)
|
|
1529
|
+
return;
|
|
1530
|
+
var completionsForEmpty = [{
|
|
1531
|
+
caption: config.nls("Loading..."),
|
|
1532
|
+
value: ""
|
|
1533
|
+
}];
|
|
1534
|
+
this.completions = new FilteredList(completionsForEmpty);
|
|
1535
|
+
this.openPopup(this.editor, initialPosition.prefix, false);
|
|
1536
|
+
this.popup.renderer.setStyle("ace_loading", true);
|
|
1537
|
+
}.bind(this), this.stickySelectionDelay);
|
|
1538
|
+
}
|
|
1539
|
+
Autocomplete.prototype.$init = function () {
|
|
1540
|
+
this.popup = new AcePopup(this.parentNode || document.body || document.documentElement);
|
|
1541
|
+
this.popup.on("click", function (e) {
|
|
1446
1542
|
this.insertMatch();
|
|
1447
1543
|
e.stop();
|
|
1448
1544
|
}.bind(this));
|
|
1449
1545
|
this.popup.focus = this.editor.focus.bind(this.editor);
|
|
1450
|
-
this.popup.on("show", this.
|
|
1451
|
-
this.popup.on("
|
|
1546
|
+
this.popup.on("show", this.$onPopupShow.bind(this));
|
|
1547
|
+
this.popup.on("hide", this.$onHidePopup.bind(this));
|
|
1548
|
+
this.popup.on("select", this.$onPopupChange.bind(this));
|
|
1549
|
+
event.addListener(this.popup.container, "mouseout", this.mouseOutListener.bind(this));
|
|
1452
1550
|
this.popup.on("changeHoverMarker", this.tooltipTimer.bind(null, null));
|
|
1453
1551
|
return this.popup;
|
|
1454
1552
|
};
|
|
1455
|
-
|
|
1456
|
-
|
|
1553
|
+
Autocomplete.prototype.$initInline = function () {
|
|
1554
|
+
if (!this.inlineEnabled || this.inlineRenderer)
|
|
1555
|
+
return;
|
|
1556
|
+
this.inlineRenderer = new AceInline();
|
|
1557
|
+
return this.inlineRenderer;
|
|
1558
|
+
};
|
|
1559
|
+
Autocomplete.prototype.getPopup = function () {
|
|
1457
1560
|
return this.popup || this.$init();
|
|
1458
1561
|
};
|
|
1459
|
-
|
|
1460
|
-
|
|
1562
|
+
Autocomplete.prototype.$onHidePopup = function () {
|
|
1563
|
+
if (this.inlineRenderer) {
|
|
1564
|
+
this.inlineRenderer.hide();
|
|
1565
|
+
}
|
|
1566
|
+
this.hideDocTooltip();
|
|
1567
|
+
this.stickySelectionTimer.cancel();
|
|
1568
|
+
this.stickySelection = false;
|
|
1569
|
+
};
|
|
1570
|
+
Autocomplete.prototype.$onPopupChange = function (hide) {
|
|
1571
|
+
if (this.inlineRenderer && this.inlineEnabled) {
|
|
1572
|
+
var completion = hide ? null : this.popup.getData(this.popup.getRow());
|
|
1573
|
+
var prefix = util.getCompletionPrefix(this.editor);
|
|
1574
|
+
if (!this.inlineRenderer.show(this.editor, completion, prefix)) {
|
|
1575
|
+
this.inlineRenderer.hide();
|
|
1576
|
+
}
|
|
1577
|
+
if (this.popup.isMouseOver && this.setSelectOnHover) {
|
|
1578
|
+
this.tooltipTimer.call(null, null);
|
|
1579
|
+
return;
|
|
1580
|
+
}
|
|
1581
|
+
}
|
|
1582
|
+
this.$updatePopupPosition();
|
|
1583
|
+
this.tooltipTimer.call(null, null);
|
|
1584
|
+
};
|
|
1585
|
+
Autocomplete.prototype.$onPopupShow = function (hide) {
|
|
1586
|
+
this.$onPopupChange(hide);
|
|
1587
|
+
this.stickySelection = false;
|
|
1588
|
+
if (this.stickySelectionDelay >= 0)
|
|
1589
|
+
this.stickySelectionTimer.schedule(this.stickySelectionDelay);
|
|
1590
|
+
};
|
|
1591
|
+
Autocomplete.prototype.observeLayoutChanges = function () {
|
|
1592
|
+
if (this.$elements || !this.editor)
|
|
1593
|
+
return;
|
|
1594
|
+
window.addEventListener("resize", this.onLayoutChange, { passive: true });
|
|
1595
|
+
window.addEventListener("wheel", this.mousewheelListener);
|
|
1596
|
+
var el = this.editor.container.parentNode;
|
|
1597
|
+
var elements = [];
|
|
1598
|
+
while (el) {
|
|
1599
|
+
elements.push(el);
|
|
1600
|
+
el.addEventListener("scroll", this.onLayoutChange, { passive: true });
|
|
1601
|
+
el = el.parentNode;
|
|
1602
|
+
}
|
|
1603
|
+
this.$elements = elements;
|
|
1604
|
+
};
|
|
1605
|
+
Autocomplete.prototype.unObserveLayoutChanges = function () {
|
|
1606
|
+
var _this = this;
|
|
1607
|
+
window.removeEventListener("resize", this.onLayoutChange, { passive: true });
|
|
1608
|
+
window.removeEventListener("wheel", this.mousewheelListener);
|
|
1609
|
+
this.$elements && this.$elements.forEach(function (el) {
|
|
1610
|
+
el.removeEventListener("scroll", _this.onLayoutChange, { passive: true });
|
|
1611
|
+
});
|
|
1612
|
+
this.$elements = null;
|
|
1613
|
+
};
|
|
1614
|
+
Autocomplete.prototype.onLayoutChange = function () {
|
|
1615
|
+
if (!this.popup.isOpen)
|
|
1616
|
+
return this.unObserveLayoutChanges();
|
|
1617
|
+
this.$updatePopupPosition();
|
|
1618
|
+
this.updateDocTooltip();
|
|
1619
|
+
};
|
|
1620
|
+
Autocomplete.prototype.$updatePopupPosition = function () {
|
|
1621
|
+
var editor = this.editor;
|
|
1622
|
+
var renderer = editor.renderer;
|
|
1623
|
+
var lineHeight = renderer.layerConfig.lineHeight;
|
|
1624
|
+
var pos = renderer.$cursorLayer.getPixelPosition(this.base, true);
|
|
1625
|
+
pos.left -= this.popup.getTextLeftOffset();
|
|
1626
|
+
var rect = editor.container.getBoundingClientRect();
|
|
1627
|
+
pos.top += rect.top - renderer.layerConfig.offset;
|
|
1628
|
+
pos.left += rect.left - editor.renderer.scrollLeft;
|
|
1629
|
+
pos.left += renderer.gutterWidth;
|
|
1630
|
+
var posGhostText = {
|
|
1631
|
+
top: pos.top,
|
|
1632
|
+
left: pos.left
|
|
1633
|
+
};
|
|
1634
|
+
if (renderer.$ghostText && renderer.$ghostTextWidget) {
|
|
1635
|
+
if (this.base.row === renderer.$ghostText.position.row) {
|
|
1636
|
+
posGhostText.top += renderer.$ghostTextWidget.el.offsetHeight;
|
|
1637
|
+
}
|
|
1638
|
+
}
|
|
1639
|
+
if (this.popup.tryShow(posGhostText, lineHeight, "bottom")) {
|
|
1640
|
+
return;
|
|
1641
|
+
}
|
|
1642
|
+
if (this.popup.tryShow(pos, lineHeight, "top")) {
|
|
1643
|
+
return;
|
|
1644
|
+
}
|
|
1645
|
+
this.popup.show(pos, lineHeight);
|
|
1646
|
+
};
|
|
1647
|
+
Autocomplete.prototype.openPopup = function (editor, prefix, keepPopupPosition) {
|
|
1648
|
+
this.$firstOpenTimer.cancel();
|
|
1461
1649
|
if (!this.popup)
|
|
1462
1650
|
this.$init();
|
|
1463
|
-
|
|
1651
|
+
if (this.inlineEnabled && !this.inlineRenderer)
|
|
1652
|
+
this.$initInline();
|
|
1464
1653
|
this.popup.autoSelect = this.autoSelect;
|
|
1465
|
-
|
|
1654
|
+
this.popup.setSelectOnHover(this.setSelectOnHover);
|
|
1655
|
+
var previousSelectedItem = this.popup.data[this.popup.getRow()];
|
|
1466
1656
|
this.popup.setData(this.completions.filtered, this.completions.filterText);
|
|
1467
|
-
|
|
1657
|
+
if (this.editor.textInput.setAriaOptions) {
|
|
1658
|
+
this.editor.textInput.setAriaOptions({
|
|
1659
|
+
activeDescendant: getAriaId(this.popup.getRow()),
|
|
1660
|
+
inline: this.inlineEnabled
|
|
1661
|
+
});
|
|
1662
|
+
}
|
|
1468
1663
|
editor.keyBinding.addKeyboardHandler(this.keyboardHandler);
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1664
|
+
var newRow = this.popup.data.indexOf(previousSelectedItem);
|
|
1665
|
+
if (newRow && this.stickySelection)
|
|
1666
|
+
this.popup.setRow(this.autoSelect ? newRow : -1);
|
|
1667
|
+
else
|
|
1668
|
+
this.popup.setRow(this.autoSelect ? 0 : -1);
|
|
1472
1669
|
if (!keepPopupPosition) {
|
|
1473
1670
|
this.popup.setTheme(editor.getTheme());
|
|
1474
1671
|
this.popup.setFontSize(editor.getFontSize());
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
var rect = editor.container.getBoundingClientRect();
|
|
1482
|
-
pos.top += rect.top - renderer.layerConfig.offset;
|
|
1483
|
-
pos.left += rect.left - editor.renderer.scrollLeft;
|
|
1484
|
-
pos.left += renderer.gutterWidth;
|
|
1485
|
-
|
|
1486
|
-
this.popup.show(pos, lineHeight);
|
|
1487
|
-
} else if (keepPopupPosition && !prefix) {
|
|
1672
|
+
this.$updatePopupPosition();
|
|
1673
|
+
if (this.tooltipNode) {
|
|
1674
|
+
this.updateDocTooltip();
|
|
1675
|
+
}
|
|
1676
|
+
}
|
|
1677
|
+
else if (keepPopupPosition && !prefix) {
|
|
1488
1678
|
this.detach();
|
|
1489
1679
|
}
|
|
1490
1680
|
this.changeTimer.cancel();
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
this.editor
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1681
|
+
this.observeLayoutChanges();
|
|
1682
|
+
};
|
|
1683
|
+
Autocomplete.prototype.detach = function () {
|
|
1684
|
+
if (this.editor) {
|
|
1685
|
+
this.editor.keyBinding.removeKeyboardHandler(this.keyboardHandler);
|
|
1686
|
+
this.editor.off("changeSelection", this.changeListener);
|
|
1687
|
+
this.editor.off("blur", this.blurListener);
|
|
1688
|
+
this.editor.off("mousedown", this.mousedownListener);
|
|
1689
|
+
this.editor.off("mousewheel", this.mousewheelListener);
|
|
1690
|
+
}
|
|
1691
|
+
this.$firstOpenTimer.cancel();
|
|
1499
1692
|
this.changeTimer.cancel();
|
|
1500
1693
|
this.hideDocTooltip();
|
|
1501
|
-
|
|
1502
|
-
|
|
1694
|
+
if (this.completionProvider) {
|
|
1695
|
+
this.completionProvider.detach();
|
|
1696
|
+
}
|
|
1503
1697
|
if (this.popup && this.popup.isOpen)
|
|
1504
1698
|
this.popup.hide();
|
|
1505
|
-
|
|
1506
1699
|
if (this.base)
|
|
1507
1700
|
this.base.detach();
|
|
1508
1701
|
this.activated = false;
|
|
1509
|
-
this.completions = this.base = null;
|
|
1702
|
+
this.completionProvider = this.completions = this.base = null;
|
|
1703
|
+
this.unObserveLayoutChanges();
|
|
1510
1704
|
};
|
|
1511
|
-
|
|
1512
|
-
this.changeListener = function(e) {
|
|
1705
|
+
Autocomplete.prototype.changeListener = function (e) {
|
|
1513
1706
|
var cursor = this.editor.selection.lead;
|
|
1514
1707
|
if (cursor.row != this.base.row || cursor.column < this.base.column) {
|
|
1515
1708
|
this.detach();
|
|
@@ -1519,144 +1712,83 @@ var Autocomplete = function() {
|
|
|
1519
1712
|
else
|
|
1520
1713
|
this.detach();
|
|
1521
1714
|
};
|
|
1522
|
-
|
|
1523
|
-
this.blurListener = function(e) {
|
|
1715
|
+
Autocomplete.prototype.blurListener = function (e) {
|
|
1524
1716
|
var el = document.activeElement;
|
|
1525
1717
|
var text = this.editor.textInput.getElement();
|
|
1526
1718
|
var fromTooltip = e.relatedTarget && this.tooltipNode && this.tooltipNode.contains(e.relatedTarget);
|
|
1527
1719
|
var container = this.popup && this.popup.container;
|
|
1528
1720
|
if (el != text && el.parentNode != container && !fromTooltip
|
|
1529
|
-
&& el != this.tooltipNode && e.relatedTarget != text
|
|
1530
|
-
) {
|
|
1721
|
+
&& el != this.tooltipNode && e.relatedTarget != text) {
|
|
1531
1722
|
this.detach();
|
|
1532
1723
|
}
|
|
1533
1724
|
};
|
|
1534
|
-
|
|
1535
|
-
this.mousedownListener = function(e) {
|
|
1725
|
+
Autocomplete.prototype.mousedownListener = function (e) {
|
|
1536
1726
|
this.detach();
|
|
1537
1727
|
};
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1728
|
+
Autocomplete.prototype.mousewheelListener = function (e) {
|
|
1729
|
+
if (!this.popup.isMouseOver)
|
|
1730
|
+
this.detach();
|
|
1541
1731
|
};
|
|
1542
|
-
|
|
1543
|
-
|
|
1732
|
+
Autocomplete.prototype.mouseOutListener = function (e) {
|
|
1733
|
+
if (this.popup.isOpen)
|
|
1734
|
+
this.$updatePopupPosition();
|
|
1735
|
+
};
|
|
1736
|
+
Autocomplete.prototype.goTo = function (where) {
|
|
1544
1737
|
this.popup.goTo(where);
|
|
1545
1738
|
};
|
|
1546
|
-
|
|
1547
|
-
this.insertMatch = function(data, options) {
|
|
1739
|
+
Autocomplete.prototype.insertMatch = function (data, options) {
|
|
1548
1740
|
if (!data)
|
|
1549
1741
|
data = this.popup.getData(this.popup.getRow());
|
|
1550
1742
|
if (!data)
|
|
1551
1743
|
return false;
|
|
1552
|
-
|
|
1744
|
+
if (data.value === "") // Explicitly given nothing to insert, e.g. "No suggestion state"
|
|
1745
|
+
return this.detach();
|
|
1553
1746
|
var completions = this.completions;
|
|
1554
|
-
this.
|
|
1555
|
-
if (data.completer && data.completer.insertMatch) {
|
|
1556
|
-
data.completer.insertMatch(this.editor, data);
|
|
1557
|
-
} else {
|
|
1558
|
-
if (completions.filterText) {
|
|
1559
|
-
var ranges = this.editor.selection.getAllRanges();
|
|
1560
|
-
for (var i = 0, range; range = ranges[i]; i++) {
|
|
1561
|
-
range.start.column -= completions.filterText.length;
|
|
1562
|
-
this.editor.session.remove(range);
|
|
1563
|
-
}
|
|
1564
|
-
}
|
|
1565
|
-
if (data.snippet)
|
|
1566
|
-
snippetManager.insertSnippet(this.editor, data.snippet);
|
|
1567
|
-
else
|
|
1568
|
-
this.editor.execCommand("insertstring", data.value || data);
|
|
1569
|
-
}
|
|
1747
|
+
var result = this.getCompletionProvider().insertMatch(this.editor, data, completions.filterText, options);
|
|
1570
1748
|
if (this.completions == completions)
|
|
1571
1749
|
this.detach();
|
|
1572
|
-
|
|
1573
|
-
};
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
this.commands = {
|
|
1577
|
-
"Up": function(editor) { editor.completer.goTo("up"); },
|
|
1578
|
-
"Down": function(editor) { editor.completer.goTo("down"); },
|
|
1579
|
-
"Ctrl-Up|Ctrl-Home": function(editor) { editor.completer.goTo("start"); },
|
|
1580
|
-
"Ctrl-Down|Ctrl-End": function(editor) { editor.completer.goTo("end"); },
|
|
1581
|
-
|
|
1582
|
-
"Esc": function(editor) { editor.completer.detach(); },
|
|
1583
|
-
"Return": function(editor) { return editor.completer.insertMatch(); },
|
|
1584
|
-
"Shift-Return": function(editor) { editor.completer.insertMatch(null, {deleteSuffix: true}); },
|
|
1585
|
-
"Tab": function(editor) {
|
|
1586
|
-
var result = editor.completer.insertMatch();
|
|
1587
|
-
if (!result && !editor.tabstopManager)
|
|
1588
|
-
editor.completer.goTo("down");
|
|
1589
|
-
else
|
|
1590
|
-
return result;
|
|
1591
|
-
},
|
|
1592
|
-
|
|
1593
|
-
"PageUp": function(editor) { editor.completer.popup.gotoPageUp(); },
|
|
1594
|
-
"PageDown": function(editor) { editor.completer.popup.gotoPageDown(); }
|
|
1595
|
-
};
|
|
1596
|
-
|
|
1597
|
-
this.gatherCompletions = function(editor, callback) {
|
|
1598
|
-
var session = editor.getSession();
|
|
1599
|
-
var pos = editor.getCursorPosition();
|
|
1600
|
-
|
|
1601
|
-
var prefix = util.getCompletionPrefix(editor);
|
|
1602
|
-
|
|
1603
|
-
this.base = session.doc.createAnchor(pos.row, pos.column - prefix.length);
|
|
1604
|
-
this.base.$insertRight = true;
|
|
1605
|
-
|
|
1606
|
-
var matches = [];
|
|
1607
|
-
var total = editor.completers.length;
|
|
1608
|
-
editor.completers.forEach(function(completer, i) {
|
|
1609
|
-
completer.getCompletions(editor, session, pos, prefix, function(err, results) {
|
|
1610
|
-
if (!err && results)
|
|
1611
|
-
matches = matches.concat(results);
|
|
1612
|
-
callback(null, {
|
|
1613
|
-
prefix: util.getCompletionPrefix(editor),
|
|
1614
|
-
matches: matches,
|
|
1615
|
-
finished: (--total === 0)
|
|
1616
|
-
});
|
|
1617
|
-
});
|
|
1618
|
-
});
|
|
1619
|
-
return true;
|
|
1750
|
+
return result;
|
|
1620
1751
|
};
|
|
1621
|
-
|
|
1622
|
-
this.showPopup = function(editor, options) {
|
|
1752
|
+
Autocomplete.prototype.showPopup = function (editor, options) {
|
|
1623
1753
|
if (this.editor)
|
|
1624
1754
|
this.detach();
|
|
1625
|
-
|
|
1626
1755
|
this.activated = true;
|
|
1627
|
-
|
|
1628
1756
|
this.editor = editor;
|
|
1629
1757
|
if (editor.completer != this) {
|
|
1630
1758
|
if (editor.completer)
|
|
1631
1759
|
editor.completer.detach();
|
|
1632
1760
|
editor.completer = this;
|
|
1633
1761
|
}
|
|
1634
|
-
|
|
1635
1762
|
editor.on("changeSelection", this.changeListener);
|
|
1636
1763
|
editor.on("blur", this.blurListener);
|
|
1637
1764
|
editor.on("mousedown", this.mousedownListener);
|
|
1638
1765
|
editor.on("mousewheel", this.mousewheelListener);
|
|
1639
|
-
|
|
1640
1766
|
this.updateCompletions(false, options);
|
|
1641
1767
|
};
|
|
1642
|
-
|
|
1643
|
-
|
|
1768
|
+
Autocomplete.prototype.getCompletionProvider = function (initialPosition) {
|
|
1769
|
+
if (!this.completionProvider)
|
|
1770
|
+
this.completionProvider = new CompletionProvider(initialPosition);
|
|
1771
|
+
return this.completionProvider;
|
|
1772
|
+
};
|
|
1773
|
+
Autocomplete.prototype.gatherCompletions = function (editor, callback) {
|
|
1774
|
+
return this.getCompletionProvider().gatherCompletions(editor, callback);
|
|
1775
|
+
};
|
|
1776
|
+
Autocomplete.prototype.updateCompletions = function (keepPopupPosition, options) {
|
|
1644
1777
|
if (keepPopupPosition && this.base && this.completions) {
|
|
1645
1778
|
var pos = this.editor.getCursorPosition();
|
|
1646
|
-
var prefix = this.editor.session.getTextRange({start: this.base, end: pos});
|
|
1779
|
+
var prefix = this.editor.session.getTextRange({ start: this.base, end: pos });
|
|
1647
1780
|
if (prefix == this.completions.filterText)
|
|
1648
1781
|
return;
|
|
1649
1782
|
this.completions.setFilter(prefix);
|
|
1650
1783
|
if (!this.completions.filtered.length)
|
|
1651
1784
|
return this.detach();
|
|
1652
1785
|
if (this.completions.filtered.length == 1
|
|
1653
|
-
|
|
1654
|
-
|
|
1786
|
+
&& this.completions.filtered[0].value == prefix
|
|
1787
|
+
&& !this.completions.filtered[0].snippet)
|
|
1655
1788
|
return this.detach();
|
|
1656
1789
|
this.openPopup(this.editor, prefix, keepPopupPosition);
|
|
1657
1790
|
return;
|
|
1658
1791
|
}
|
|
1659
|
-
|
|
1660
1792
|
if (options && options.matches) {
|
|
1661
1793
|
var pos = this.editor.getSelectionRange().start;
|
|
1662
1794
|
this.base = this.editor.session.doc.createAnchor(pos.row, pos.column);
|
|
@@ -1664,137 +1796,134 @@ var Autocomplete = function() {
|
|
|
1664
1796
|
this.completions = new FilteredList(options.matches);
|
|
1665
1797
|
return this.openPopup(this.editor, "", keepPopupPosition);
|
|
1666
1798
|
}
|
|
1667
|
-
var
|
|
1668
|
-
var
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
this.
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
return;
|
|
1704
|
-
if (isImmediate) {
|
|
1705
|
-
immediateResults = results;
|
|
1706
|
-
return;
|
|
1799
|
+
var session = this.editor.getSession();
|
|
1800
|
+
var pos = this.editor.getCursorPosition();
|
|
1801
|
+
var prefix = util.getCompletionPrefix(this.editor);
|
|
1802
|
+
this.base = session.doc.createAnchor(pos.row, pos.column - prefix.length);
|
|
1803
|
+
this.base.$insertRight = true;
|
|
1804
|
+
var completionOptions = {
|
|
1805
|
+
exactMatch: this.exactMatch,
|
|
1806
|
+
ignoreCaption: this.ignoreCaption
|
|
1807
|
+
};
|
|
1808
|
+
this.getCompletionProvider({
|
|
1809
|
+
prefix: prefix,
|
|
1810
|
+
pos: pos
|
|
1811
|
+
}).provideCompletions(this.editor, completionOptions, function (err, completions, finished) {
|
|
1812
|
+
var filtered = completions.filtered;
|
|
1813
|
+
var prefix = util.getCompletionPrefix(this.editor);
|
|
1814
|
+
this.$firstOpenTimer.cancel();
|
|
1815
|
+
if (finished) {
|
|
1816
|
+
if (!filtered.length) {
|
|
1817
|
+
var emptyMessage = !this.autoShown && this.emptyMessage;
|
|
1818
|
+
if (typeof emptyMessage == "function")
|
|
1819
|
+
emptyMessage = this.emptyMessage(prefix);
|
|
1820
|
+
if (emptyMessage) {
|
|
1821
|
+
var completionsForEmpty = [{
|
|
1822
|
+
caption: emptyMessage,
|
|
1823
|
+
value: ""
|
|
1824
|
+
}];
|
|
1825
|
+
this.completions = new FilteredList(completionsForEmpty);
|
|
1826
|
+
this.openPopup(this.editor, prefix, keepPopupPosition);
|
|
1827
|
+
return;
|
|
1828
|
+
}
|
|
1829
|
+
return this.detach();
|
|
1830
|
+
}
|
|
1831
|
+
if (filtered.length == 1 && filtered[0].value == prefix && !filtered[0].snippet)
|
|
1832
|
+
return this.detach();
|
|
1833
|
+
if (this.autoInsert && !this.autoShown && filtered.length == 1)
|
|
1834
|
+
return this.insertMatch(filtered[0]);
|
|
1707
1835
|
}
|
|
1708
|
-
|
|
1709
|
-
|
|
1836
|
+
this.completions = completions;
|
|
1837
|
+
this.openPopup(this.editor, prefix, keepPopupPosition);
|
|
1838
|
+
this.popup.renderer.setStyle("ace_loading", !finished);
|
|
1710
1839
|
}.bind(this));
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
if (immediateResults) {
|
|
1714
|
-
var results = immediateResults;
|
|
1715
|
-
immediateResults = null;
|
|
1716
|
-
processResults(results);
|
|
1840
|
+
if (!this.autoShown && !(this.popup && this.popup.isOpen)) {
|
|
1841
|
+
this.$firstOpenTimer.delay(this.stickySelectionDelay / 2);
|
|
1717
1842
|
}
|
|
1718
1843
|
};
|
|
1719
|
-
|
|
1720
|
-
this.cancelContextMenu = function() {
|
|
1844
|
+
Autocomplete.prototype.cancelContextMenu = function () {
|
|
1721
1845
|
this.editor.$mouseHandler.cancelContextMenu();
|
|
1722
1846
|
};
|
|
1723
|
-
|
|
1724
|
-
this.updateDocTooltip = function() {
|
|
1847
|
+
Autocomplete.prototype.updateDocTooltip = function () {
|
|
1725
1848
|
var popup = this.popup;
|
|
1726
|
-
var all =
|
|
1849
|
+
var all = this.completions.filtered;
|
|
1727
1850
|
var selected = all && (all[popup.getHoveredRow()] || all[popup.getRow()]);
|
|
1728
1851
|
var doc = null;
|
|
1729
1852
|
if (!selected || !this.editor || !this.popup.isOpen)
|
|
1730
1853
|
return this.hideDocTooltip();
|
|
1731
|
-
this.editor.completers.
|
|
1732
|
-
|
|
1854
|
+
var completersLength = this.editor.completers.length;
|
|
1855
|
+
for (var i = 0; i < completersLength; i++) {
|
|
1856
|
+
var completer = this.editor.completers[i];
|
|
1857
|
+
if (completer.getDocTooltip && selected.completerId === completer.id) {
|
|
1733
1858
|
doc = completer.getDocTooltip(selected);
|
|
1734
|
-
|
|
1735
|
-
|
|
1859
|
+
break;
|
|
1860
|
+
}
|
|
1861
|
+
}
|
|
1736
1862
|
if (!doc && typeof selected != "string")
|
|
1737
1863
|
doc = selected;
|
|
1738
|
-
|
|
1739
1864
|
if (typeof doc == "string")
|
|
1740
|
-
doc = {docText: doc};
|
|
1865
|
+
doc = { docText: doc };
|
|
1741
1866
|
if (!doc || !(doc.docHTML || doc.docText))
|
|
1742
1867
|
return this.hideDocTooltip();
|
|
1743
1868
|
this.showDocTooltip(doc);
|
|
1744
1869
|
};
|
|
1745
|
-
|
|
1746
|
-
this.showDocTooltip = function(item) {
|
|
1870
|
+
Autocomplete.prototype.showDocTooltip = function (item) {
|
|
1747
1871
|
if (!this.tooltipNode) {
|
|
1748
1872
|
this.tooltipNode = dom.createElement("div");
|
|
1749
|
-
this.tooltipNode.className = "ace_tooltip ace_doc-tooltip";
|
|
1750
1873
|
this.tooltipNode.style.margin = 0;
|
|
1751
1874
|
this.tooltipNode.style.pointerEvents = "auto";
|
|
1752
1875
|
this.tooltipNode.tabIndex = -1;
|
|
1753
1876
|
this.tooltipNode.onblur = this.blurListener.bind(this);
|
|
1754
1877
|
this.tooltipNode.onclick = this.onTooltipClick.bind(this);
|
|
1878
|
+
this.tooltipNode.id = "doc-tooltip";
|
|
1879
|
+
this.tooltipNode.setAttribute("role", "tooltip");
|
|
1755
1880
|
}
|
|
1756
|
-
|
|
1881
|
+
var theme = this.editor.renderer.theme;
|
|
1882
|
+
this.tooltipNode.className = "ace_tooltip ace_doc-tooltip " +
|
|
1883
|
+
(theme.isDark ? "ace_dark " : "") + (theme.cssClass || "");
|
|
1757
1884
|
var tooltipNode = this.tooltipNode;
|
|
1758
1885
|
if (item.docHTML) {
|
|
1759
1886
|
tooltipNode.innerHTML = item.docHTML;
|
|
1760
|
-
}
|
|
1887
|
+
}
|
|
1888
|
+
else if (item.docText) {
|
|
1761
1889
|
tooltipNode.textContent = item.docText;
|
|
1762
1890
|
}
|
|
1763
|
-
|
|
1764
1891
|
if (!tooltipNode.parentNode)
|
|
1765
|
-
|
|
1892
|
+
this.popup.container.appendChild(this.tooltipNode);
|
|
1766
1893
|
var popup = this.popup;
|
|
1767
1894
|
var rect = popup.container.getBoundingClientRect();
|
|
1768
1895
|
tooltipNode.style.top = popup.container.style.top;
|
|
1769
1896
|
tooltipNode.style.bottom = popup.container.style.bottom;
|
|
1770
|
-
|
|
1771
1897
|
tooltipNode.style.display = "block";
|
|
1772
1898
|
if (window.innerWidth - rect.right < 320) {
|
|
1773
1899
|
if (rect.left < 320) {
|
|
1774
|
-
if(popup.isTopdown) {
|
|
1900
|
+
if (popup.isTopdown) {
|
|
1775
1901
|
tooltipNode.style.top = rect.bottom + "px";
|
|
1776
1902
|
tooltipNode.style.left = rect.left + "px";
|
|
1777
1903
|
tooltipNode.style.right = "";
|
|
1778
1904
|
tooltipNode.style.bottom = "";
|
|
1779
|
-
}
|
|
1905
|
+
}
|
|
1906
|
+
else {
|
|
1780
1907
|
tooltipNode.style.top = popup.container.offsetTop - tooltipNode.offsetHeight + "px";
|
|
1781
1908
|
tooltipNode.style.left = rect.left + "px";
|
|
1782
1909
|
tooltipNode.style.right = "";
|
|
1783
1910
|
tooltipNode.style.bottom = "";
|
|
1784
1911
|
}
|
|
1785
|
-
}
|
|
1912
|
+
}
|
|
1913
|
+
else {
|
|
1786
1914
|
tooltipNode.style.right = window.innerWidth - rect.left + "px";
|
|
1787
1915
|
tooltipNode.style.left = "";
|
|
1788
1916
|
}
|
|
1789
|
-
}
|
|
1917
|
+
}
|
|
1918
|
+
else {
|
|
1790
1919
|
tooltipNode.style.left = (rect.right + 1) + "px";
|
|
1791
1920
|
tooltipNode.style.right = "";
|
|
1792
1921
|
}
|
|
1793
1922
|
};
|
|
1794
|
-
|
|
1795
|
-
this.hideDocTooltip = function() {
|
|
1923
|
+
Autocomplete.prototype.hideDocTooltip = function () {
|
|
1796
1924
|
this.tooltipTimer.cancel();
|
|
1797
|
-
if (!this.tooltipNode)
|
|
1925
|
+
if (!this.tooltipNode)
|
|
1926
|
+
return;
|
|
1798
1927
|
var el = this.tooltipNode;
|
|
1799
1928
|
if (!this.editor.isFocused() && document.activeElement == el)
|
|
1800
1929
|
this.editor.focus();
|
|
@@ -1802,8 +1931,7 @@ var Autocomplete = function() {
|
|
|
1802
1931
|
if (el.parentNode)
|
|
1803
1932
|
el.parentNode.removeChild(el);
|
|
1804
1933
|
};
|
|
1805
|
-
|
|
1806
|
-
this.onTooltipClick = function(e) {
|
|
1934
|
+
Autocomplete.prototype.onTooltipClick = function (e) {
|
|
1807
1935
|
var a = e.target;
|
|
1808
1936
|
while (a && a != this.tooltipNode) {
|
|
1809
1937
|
if (a.nodeName == "A" && a.href) {
|
|
@@ -1814,8 +1942,7 @@ var Autocomplete = function() {
|
|
|
1814
1942
|
a = a.parentNode;
|
|
1815
1943
|
}
|
|
1816
1944
|
};
|
|
1817
|
-
|
|
1818
|
-
this.destroy = function() {
|
|
1945
|
+
Autocomplete.prototype.destroy = function () {
|
|
1819
1946
|
this.detach();
|
|
1820
1947
|
if (this.popup) {
|
|
1821
1948
|
this.popup.destroy();
|
|
@@ -1823,92 +1950,246 @@ var Autocomplete = function() {
|
|
|
1823
1950
|
if (el && el.parentNode)
|
|
1824
1951
|
el.parentNode.removeChild(el);
|
|
1825
1952
|
}
|
|
1826
|
-
if (this.editor && this.editor.completer == this)
|
|
1827
|
-
this.editor.
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
}
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
Autocomplete.
|
|
1835
|
-
|
|
1953
|
+
if (this.editor && this.editor.completer == this) {
|
|
1954
|
+
this.editor.off("destroy", destroyCompleter);
|
|
1955
|
+
this.editor.completer = null;
|
|
1956
|
+
}
|
|
1957
|
+
this.inlineRenderer = this.popup = this.editor = null;
|
|
1958
|
+
};
|
|
1959
|
+
return Autocomplete;
|
|
1960
|
+
}());
|
|
1961
|
+
Autocomplete.prototype.commands = {
|
|
1962
|
+
"Up": function (editor) { editor.completer.goTo("up"); },
|
|
1963
|
+
"Down": function (editor) { editor.completer.goTo("down"); },
|
|
1964
|
+
"Ctrl-Up|Ctrl-Home": function (editor) { editor.completer.goTo("start"); },
|
|
1965
|
+
"Ctrl-Down|Ctrl-End": function (editor) { editor.completer.goTo("end"); },
|
|
1966
|
+
"Esc": function (editor) { editor.completer.detach(); },
|
|
1967
|
+
"Return": function (editor) { return editor.completer.insertMatch(); },
|
|
1968
|
+
"Shift-Return": function (editor) { editor.completer.insertMatch(null, { deleteSuffix: true }); },
|
|
1969
|
+
"Tab": function (editor) {
|
|
1970
|
+
var result = editor.completer.insertMatch();
|
|
1971
|
+
if (!result && !editor.tabstopManager)
|
|
1972
|
+
editor.completer.goTo("down");
|
|
1973
|
+
else
|
|
1974
|
+
return result;
|
|
1975
|
+
},
|
|
1976
|
+
"PageUp": function (editor) { editor.completer.popup.gotoPageUp(); },
|
|
1977
|
+
"PageDown": function (editor) { editor.completer.popup.gotoPageDown(); }
|
|
1978
|
+
};
|
|
1979
|
+
Autocomplete.for = function (editor) {
|
|
1980
|
+
if (editor.completer instanceof Autocomplete) {
|
|
1836
1981
|
return editor.completer;
|
|
1837
1982
|
}
|
|
1983
|
+
if (editor.completer) {
|
|
1984
|
+
editor.completer.destroy();
|
|
1985
|
+
editor.completer = null;
|
|
1986
|
+
}
|
|
1838
1987
|
if (config.get("sharedPopups")) {
|
|
1839
|
-
if (!Autocomplete.$
|
|
1988
|
+
if (!Autocomplete.$sharedInstance)
|
|
1840
1989
|
Autocomplete.$sharedInstance = new Autocomplete();
|
|
1841
1990
|
editor.completer = Autocomplete.$sharedInstance;
|
|
1842
|
-
}
|
|
1991
|
+
}
|
|
1992
|
+
else {
|
|
1843
1993
|
editor.completer = new Autocomplete();
|
|
1844
|
-
editor.once("destroy",
|
|
1845
|
-
editor.completer.destroy();
|
|
1846
|
-
});
|
|
1994
|
+
editor.once("destroy", destroyCompleter);
|
|
1847
1995
|
}
|
|
1848
1996
|
return editor.completer;
|
|
1849
1997
|
};
|
|
1850
|
-
|
|
1851
1998
|
Autocomplete.startCommand = {
|
|
1852
1999
|
name: "startAutocomplete",
|
|
1853
|
-
exec: function(editor, options) {
|
|
2000
|
+
exec: function (editor, options) {
|
|
1854
2001
|
var completer = Autocomplete.for(editor);
|
|
1855
2002
|
completer.autoInsert = false;
|
|
1856
2003
|
completer.autoSelect = true;
|
|
2004
|
+
completer.autoShown = false;
|
|
1857
2005
|
completer.showPopup(editor, options);
|
|
1858
2006
|
completer.cancelContextMenu();
|
|
1859
2007
|
},
|
|
1860
2008
|
bindKey: "Ctrl-Space|Ctrl-Shift-Space|Alt-Space"
|
|
1861
2009
|
};
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
2010
|
+
var CompletionProvider = /** @class */ (function () {
|
|
2011
|
+
function CompletionProvider(initialPosition) {
|
|
2012
|
+
this.initialPosition = initialPosition;
|
|
2013
|
+
this.active = true;
|
|
2014
|
+
}
|
|
2015
|
+
CompletionProvider.prototype.insertByIndex = function (editor, index, options) {
|
|
2016
|
+
if (!this.completions || !this.completions.filtered) {
|
|
2017
|
+
return false;
|
|
2018
|
+
}
|
|
2019
|
+
return this.insertMatch(editor, this.completions.filtered[index], options);
|
|
2020
|
+
};
|
|
2021
|
+
CompletionProvider.prototype.insertMatch = function (editor, data, options) {
|
|
2022
|
+
if (!data)
|
|
2023
|
+
return false;
|
|
2024
|
+
editor.startOperation({ command: { name: "insertMatch" } });
|
|
2025
|
+
if (data.completer && data.completer.insertMatch) {
|
|
2026
|
+
data.completer.insertMatch(editor, data);
|
|
2027
|
+
}
|
|
2028
|
+
else {
|
|
2029
|
+
if (!this.completions)
|
|
2030
|
+
return false;
|
|
2031
|
+
var replaceBefore = this.completions.filterText.length;
|
|
2032
|
+
var replaceAfter = 0;
|
|
2033
|
+
if (data.range && data.range.start.row === data.range.end.row) {
|
|
2034
|
+
replaceBefore -= this.initialPosition.prefix.length;
|
|
2035
|
+
replaceBefore += this.initialPosition.pos.column - data.range.start.column;
|
|
2036
|
+
replaceAfter += data.range.end.column - this.initialPosition.pos.column;
|
|
2037
|
+
}
|
|
2038
|
+
if (replaceBefore || replaceAfter) {
|
|
2039
|
+
var ranges;
|
|
2040
|
+
if (editor.selection.getAllRanges) {
|
|
2041
|
+
ranges = editor.selection.getAllRanges();
|
|
2042
|
+
}
|
|
2043
|
+
else {
|
|
2044
|
+
ranges = [editor.getSelectionRange()];
|
|
2045
|
+
}
|
|
2046
|
+
for (var i = 0, range; range = ranges[i]; i++) {
|
|
2047
|
+
range.start.column -= replaceBefore;
|
|
2048
|
+
range.end.column += replaceAfter;
|
|
2049
|
+
editor.session.remove(range);
|
|
2050
|
+
}
|
|
2051
|
+
}
|
|
2052
|
+
if (data.snippet) {
|
|
2053
|
+
snippetManager.insertSnippet(editor, data.snippet);
|
|
2054
|
+
}
|
|
2055
|
+
else {
|
|
2056
|
+
this.$insertString(editor, data);
|
|
2057
|
+
}
|
|
2058
|
+
if (data.command && data.command === "startAutocomplete") {
|
|
2059
|
+
editor.execCommand(data.command);
|
|
2060
|
+
}
|
|
2061
|
+
}
|
|
2062
|
+
editor.endOperation();
|
|
2063
|
+
return true;
|
|
2064
|
+
};
|
|
2065
|
+
CompletionProvider.prototype.$insertString = function (editor, data) {
|
|
2066
|
+
var text = data.value || data;
|
|
2067
|
+
editor.execCommand("insertstring", text);
|
|
2068
|
+
};
|
|
2069
|
+
CompletionProvider.prototype.gatherCompletions = function (editor, callback) {
|
|
2070
|
+
var session = editor.getSession();
|
|
2071
|
+
var pos = editor.getCursorPosition();
|
|
2072
|
+
var prefix = util.getCompletionPrefix(editor);
|
|
2073
|
+
var matches = [];
|
|
2074
|
+
this.completers = editor.completers;
|
|
2075
|
+
var total = editor.completers.length;
|
|
2076
|
+
editor.completers.forEach(function (completer, i) {
|
|
2077
|
+
completer.getCompletions(editor, session, pos, prefix, function (err, results) {
|
|
2078
|
+
if (completer.hideInlinePreview)
|
|
2079
|
+
results = results.map(function (result) {
|
|
2080
|
+
return Object.assign(result, { hideInlinePreview: completer.hideInlinePreview });
|
|
2081
|
+
});
|
|
2082
|
+
if (!err && results)
|
|
2083
|
+
matches = matches.concat(results);
|
|
2084
|
+
callback(null, {
|
|
2085
|
+
prefix: util.getCompletionPrefix(editor),
|
|
2086
|
+
matches: matches,
|
|
2087
|
+
finished: (--total === 0)
|
|
2088
|
+
});
|
|
2089
|
+
});
|
|
2090
|
+
});
|
|
2091
|
+
return true;
|
|
2092
|
+
};
|
|
2093
|
+
CompletionProvider.prototype.provideCompletions = function (editor, options, callback) {
|
|
2094
|
+
var processResults = function (results) {
|
|
2095
|
+
var prefix = results.prefix;
|
|
2096
|
+
var matches = results.matches;
|
|
2097
|
+
this.completions = new FilteredList(matches);
|
|
2098
|
+
if (options.exactMatch)
|
|
2099
|
+
this.completions.exactMatch = true;
|
|
2100
|
+
if (options.ignoreCaption)
|
|
2101
|
+
this.completions.ignoreCaption = true;
|
|
2102
|
+
this.completions.setFilter(prefix);
|
|
2103
|
+
if (results.finished || this.completions.filtered.length)
|
|
2104
|
+
callback(null, this.completions, results.finished);
|
|
2105
|
+
}.bind(this);
|
|
2106
|
+
var isImmediate = true;
|
|
2107
|
+
var immediateResults = null;
|
|
2108
|
+
this.gatherCompletions(editor, function (err, results) {
|
|
2109
|
+
if (!this.active) {
|
|
2110
|
+
return;
|
|
2111
|
+
}
|
|
2112
|
+
if (err) {
|
|
2113
|
+
callback(err, [], true);
|
|
2114
|
+
this.detach();
|
|
2115
|
+
}
|
|
2116
|
+
var prefix = results.prefix;
|
|
2117
|
+
if (prefix.indexOf(results.prefix) !== 0)
|
|
2118
|
+
return;
|
|
2119
|
+
if (isImmediate) {
|
|
2120
|
+
immediateResults = results;
|
|
2121
|
+
return;
|
|
2122
|
+
}
|
|
2123
|
+
processResults(results);
|
|
2124
|
+
}.bind(this));
|
|
2125
|
+
isImmediate = false;
|
|
2126
|
+
if (immediateResults) {
|
|
2127
|
+
var results = immediateResults;
|
|
2128
|
+
immediateResults = null;
|
|
2129
|
+
processResults(results);
|
|
2130
|
+
}
|
|
2131
|
+
};
|
|
2132
|
+
CompletionProvider.prototype.detach = function () {
|
|
2133
|
+
this.active = false;
|
|
2134
|
+
this.completers && this.completers.forEach(function (completer) {
|
|
2135
|
+
if (typeof completer.cancel === "function") {
|
|
2136
|
+
completer.cancel();
|
|
2137
|
+
}
|
|
2138
|
+
});
|
|
2139
|
+
};
|
|
2140
|
+
return CompletionProvider;
|
|
2141
|
+
}());
|
|
2142
|
+
var FilteredList = /** @class */ (function () {
|
|
2143
|
+
function FilteredList(array, filterText) {
|
|
2144
|
+
this.all = array;
|
|
2145
|
+
this.filtered = array;
|
|
2146
|
+
this.filterText = filterText || "";
|
|
2147
|
+
this.exactMatch = false;
|
|
2148
|
+
this.ignoreCaption = false;
|
|
2149
|
+
}
|
|
2150
|
+
FilteredList.prototype.setFilter = function (str) {
|
|
1871
2151
|
if (str.length > this.filterText && str.lastIndexOf(this.filterText, 0) === 0)
|
|
1872
2152
|
var matches = this.filtered;
|
|
1873
2153
|
else
|
|
1874
2154
|
var matches = this.all;
|
|
1875
|
-
|
|
1876
2155
|
this.filterText = str;
|
|
1877
2156
|
matches = this.filterCompletions(matches, this.filterText);
|
|
1878
|
-
matches = matches.sort(function(a, b) {
|
|
1879
|
-
return b.exactMatch - a.exactMatch || b.$score - a.$score
|
|
2157
|
+
matches = matches.sort(function (a, b) {
|
|
2158
|
+
return b.exactMatch - a.exactMatch || b.$score - a.$score
|
|
1880
2159
|
|| (a.caption || a.value).localeCompare(b.caption || b.value);
|
|
1881
2160
|
});
|
|
1882
2161
|
var prev = null;
|
|
1883
|
-
matches = matches.filter(function(item){
|
|
2162
|
+
matches = matches.filter(function (item) {
|
|
1884
2163
|
var caption = item.snippet || item.caption || item.value;
|
|
1885
|
-
if (caption === prev)
|
|
2164
|
+
if (caption === prev)
|
|
2165
|
+
return false;
|
|
1886
2166
|
prev = caption;
|
|
1887
2167
|
return true;
|
|
1888
2168
|
});
|
|
1889
|
-
|
|
1890
2169
|
this.filtered = matches;
|
|
1891
2170
|
};
|
|
1892
|
-
|
|
2171
|
+
FilteredList.prototype.filterCompletions = function (items, needle) {
|
|
1893
2172
|
var results = [];
|
|
1894
2173
|
var upper = needle.toUpperCase();
|
|
1895
2174
|
var lower = needle.toLowerCase();
|
|
1896
2175
|
loop: for (var i = 0, item; item = items[i]; i++) {
|
|
1897
|
-
var caption = item.caption || item.value || item.snippet;
|
|
1898
|
-
if (!caption)
|
|
2176
|
+
var caption = (!this.ignoreCaption && item.caption) || item.value || item.snippet;
|
|
2177
|
+
if (!caption)
|
|
2178
|
+
continue;
|
|
1899
2179
|
var lastIndex = -1;
|
|
1900
2180
|
var matchMask = 0;
|
|
1901
2181
|
var penalty = 0;
|
|
1902
2182
|
var index, distance;
|
|
1903
|
-
|
|
1904
2183
|
if (this.exactMatch) {
|
|
1905
2184
|
if (needle !== caption.substr(0, needle.length))
|
|
1906
2185
|
continue loop;
|
|
1907
|
-
}
|
|
2186
|
+
}
|
|
2187
|
+
else {
|
|
1908
2188
|
var fullMatchIndex = caption.toLowerCase().indexOf(lower);
|
|
1909
2189
|
if (fullMatchIndex > -1) {
|
|
1910
2190
|
penalty = fullMatchIndex;
|
|
1911
|
-
}
|
|
2191
|
+
}
|
|
2192
|
+
else {
|
|
1912
2193
|
for (var j = 0; j < needle.length; j++) {
|
|
1913
2194
|
var i1 = caption.indexOf(lower[j], lastIndex + 1);
|
|
1914
2195
|
var i2 = caption.indexOf(upper[j], lastIndex + 1);
|
|
@@ -1933,90 +2214,98 @@ var FilteredList = function(array, filterText) {
|
|
|
1933
2214
|
}
|
|
1934
2215
|
return results;
|
|
1935
2216
|
};
|
|
1936
|
-
|
|
1937
|
-
|
|
2217
|
+
return FilteredList;
|
|
2218
|
+
}());
|
|
1938
2219
|
exports.Autocomplete = Autocomplete;
|
|
2220
|
+
exports.CompletionProvider = CompletionProvider;
|
|
1939
2221
|
exports.FilteredList = FilteredList;
|
|
1940
2222
|
|
|
1941
2223
|
});
|
|
1942
2224
|
|
|
1943
|
-
ace.define("ace/autocomplete/text_completer",[], function(require, exports, module)
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
var
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
2225
|
+
ace.define("ace/autocomplete/text_completer",["require","exports","module","ace/range"], function(require, exports, module){var Range = require("../range").Range;
|
|
2226
|
+
var splitRegex = /[^a-zA-Z_0-9\$\-\u00C0-\u1FFF\u2C00-\uD7FF\w]+/;
|
|
2227
|
+
function getWordIndex(doc, pos) {
|
|
2228
|
+
var textBefore = doc.getTextRange(Range.fromPoints({
|
|
2229
|
+
row: 0,
|
|
2230
|
+
column: 0
|
|
2231
|
+
}, pos));
|
|
2232
|
+
return textBefore.split(splitRegex).length - 1;
|
|
2233
|
+
}
|
|
2234
|
+
function wordDistance(doc, pos) {
|
|
2235
|
+
var prefixPos = getWordIndex(doc, pos);
|
|
2236
|
+
var words = doc.getValue().split(splitRegex);
|
|
2237
|
+
var wordScores = Object.create(null);
|
|
2238
|
+
var currentWord = words[prefixPos];
|
|
2239
|
+
words.forEach(function (word, idx) {
|
|
2240
|
+
if (!word || word === currentWord)
|
|
2241
|
+
return;
|
|
2242
|
+
var distance = Math.abs(prefixPos - idx);
|
|
2243
|
+
var score = words.length - distance;
|
|
2244
|
+
if (wordScores[word]) {
|
|
2245
|
+
wordScores[word] = Math.max(score, wordScores[word]);
|
|
2246
|
+
}
|
|
2247
|
+
else {
|
|
2248
|
+
wordScores[word] = score;
|
|
2249
|
+
}
|
|
2250
|
+
});
|
|
2251
|
+
return wordScores;
|
|
2252
|
+
}
|
|
2253
|
+
exports.getCompletions = function (editor, session, pos, prefix, callback) {
|
|
2254
|
+
var wordScore = wordDistance(session, pos);
|
|
2255
|
+
var wordList = Object.keys(wordScore);
|
|
2256
|
+
callback(null, wordList.map(function (word) {
|
|
2257
|
+
return {
|
|
2258
|
+
caption: word,
|
|
2259
|
+
value: word,
|
|
2260
|
+
score: wordScore[word],
|
|
2261
|
+
meta: "local"
|
|
2262
|
+
};
|
|
2263
|
+
}));
|
|
2264
|
+
};
|
|
1972
2265
|
|
|
1973
|
-
exports.getCompletions = function(editor, session, pos, prefix, callback) {
|
|
1974
|
-
var wordScore = wordDistance(session, pos);
|
|
1975
|
-
var wordList = Object.keys(wordScore);
|
|
1976
|
-
callback(null, wordList.map(function(word) {
|
|
1977
|
-
return {
|
|
1978
|
-
caption: word,
|
|
1979
|
-
value: word,
|
|
1980
|
-
score: wordScore[word],
|
|
1981
|
-
meta: "local"
|
|
1982
|
-
};
|
|
1983
|
-
}));
|
|
1984
|
-
};
|
|
1985
2266
|
});
|
|
1986
2267
|
|
|
1987
|
-
ace.define("ace/ext/language_tools",[], function(require, exports, module)
|
|
1988
|
-
"use strict";
|
|
1989
|
-
|
|
2268
|
+
ace.define("ace/ext/language_tools",["require","exports","module","ace/snippets","ace/autocomplete","ace/config","ace/lib/lang","ace/autocomplete/util","ace/autocomplete/text_completer","ace/editor","ace/config"], function(require, exports, module){"use strict";
|
|
1990
2269
|
var snippetManager = require("../snippets").snippetManager;
|
|
1991
2270
|
var Autocomplete = require("../autocomplete").Autocomplete;
|
|
1992
2271
|
var config = require("../config");
|
|
1993
2272
|
var lang = require("../lib/lang");
|
|
1994
2273
|
var util = require("../autocomplete/util");
|
|
1995
|
-
|
|
1996
2274
|
var textCompleter = require("../autocomplete/text_completer");
|
|
1997
2275
|
var keyWordCompleter = {
|
|
1998
|
-
getCompletions: function(editor, session, pos, prefix, callback) {
|
|
2276
|
+
getCompletions: function (editor, session, pos, prefix, callback) {
|
|
1999
2277
|
if (session.$mode.completer) {
|
|
2000
2278
|
return session.$mode.completer.getCompletions(editor, session, pos, prefix, callback);
|
|
2001
2279
|
}
|
|
2002
2280
|
var state = editor.session.getState(pos.row);
|
|
2003
2281
|
var completions = session.$mode.getCompletions(state, session, pos, prefix);
|
|
2282
|
+
completions = completions.map(function (el) {
|
|
2283
|
+
el.completerId = keyWordCompleter.id;
|
|
2284
|
+
return el;
|
|
2285
|
+
});
|
|
2004
2286
|
callback(null, completions);
|
|
2005
|
-
}
|
|
2287
|
+
},
|
|
2288
|
+
id: "keywordCompleter"
|
|
2289
|
+
};
|
|
2290
|
+
var transformSnippetTooltip = function (str) {
|
|
2291
|
+
var record = {};
|
|
2292
|
+
return str.replace(/\${(\d+)(:(.*?))?}/g, function (_, p1, p2, p3) {
|
|
2293
|
+
return (record[p1] = p3 || '');
|
|
2294
|
+
}).replace(/\$(\d+?)/g, function (_, p1) {
|
|
2295
|
+
return record[p1];
|
|
2296
|
+
});
|
|
2006
2297
|
};
|
|
2007
|
-
|
|
2008
2298
|
var snippetCompleter = {
|
|
2009
|
-
getCompletions: function(editor, session, pos, prefix, callback) {
|
|
2299
|
+
getCompletions: function (editor, session, pos, prefix, callback) {
|
|
2010
2300
|
var scopes = [];
|
|
2011
2301
|
var token = session.getTokenAt(pos.row, pos.column);
|
|
2012
2302
|
if (token && token.type.match(/(tag-name|tag-open|tag-whitespace|attribute-name|attribute-value)\.xml$/))
|
|
2013
2303
|
scopes.push('html-tag');
|
|
2014
2304
|
else
|
|
2015
2305
|
scopes = snippetManager.getActiveScopes(editor);
|
|
2016
|
-
|
|
2017
2306
|
var snippetMap = snippetManager.snippetMap;
|
|
2018
2307
|
var completions = [];
|
|
2019
|
-
scopes.forEach(function(scope) {
|
|
2308
|
+
scopes.forEach(function (scope) {
|
|
2020
2309
|
var snippets = snippetMap[scope] || [];
|
|
2021
2310
|
for (var i = snippets.length; i--;) {
|
|
2022
2311
|
var s = snippets[i];
|
|
@@ -2027,128 +2316,148 @@ var snippetCompleter = {
|
|
|
2027
2316
|
caption: caption,
|
|
2028
2317
|
snippet: s.content,
|
|
2029
2318
|
meta: s.tabTrigger && !s.name ? s.tabTrigger + "\u21E5 " : "snippet",
|
|
2030
|
-
|
|
2319
|
+
completerId: snippetCompleter.id
|
|
2031
2320
|
});
|
|
2032
2321
|
}
|
|
2033
2322
|
}, this);
|
|
2034
2323
|
callback(null, completions);
|
|
2035
2324
|
},
|
|
2036
|
-
getDocTooltip: function(item) {
|
|
2037
|
-
if (item.
|
|
2325
|
+
getDocTooltip: function (item) {
|
|
2326
|
+
if (item.snippet && !item.docHTML) {
|
|
2038
2327
|
item.docHTML = [
|
|
2039
2328
|
"<b>", lang.escapeHTML(item.caption), "</b>", "<hr></hr>",
|
|
2040
|
-
lang.escapeHTML(item.snippet)
|
|
2329
|
+
lang.escapeHTML(transformSnippetTooltip(item.snippet))
|
|
2041
2330
|
].join("");
|
|
2042
2331
|
}
|
|
2043
|
-
}
|
|
2332
|
+
},
|
|
2333
|
+
id: "snippetCompleter"
|
|
2044
2334
|
};
|
|
2045
|
-
|
|
2046
2335
|
var completers = [snippetCompleter, textCompleter, keyWordCompleter];
|
|
2047
|
-
exports.setCompleters = function(val) {
|
|
2336
|
+
exports.setCompleters = function (val) {
|
|
2048
2337
|
completers.length = 0;
|
|
2049
|
-
if (val)
|
|
2338
|
+
if (val)
|
|
2339
|
+
completers.push.apply(completers, val);
|
|
2050
2340
|
};
|
|
2051
|
-
exports.addCompleter = function(completer) {
|
|
2341
|
+
exports.addCompleter = function (completer) {
|
|
2052
2342
|
completers.push(completer);
|
|
2053
2343
|
};
|
|
2054
2344
|
exports.textCompleter = textCompleter;
|
|
2055
2345
|
exports.keyWordCompleter = keyWordCompleter;
|
|
2056
2346
|
exports.snippetCompleter = snippetCompleter;
|
|
2057
|
-
|
|
2058
2347
|
var expandSnippet = {
|
|
2059
2348
|
name: "expandSnippet",
|
|
2060
|
-
exec: function(editor) {
|
|
2349
|
+
exec: function (editor) {
|
|
2061
2350
|
return snippetManager.expandWithTab(editor);
|
|
2062
2351
|
},
|
|
2063
2352
|
bindKey: "Tab"
|
|
2064
2353
|
};
|
|
2065
|
-
|
|
2066
|
-
var onChangeMode = function(e, editor) {
|
|
2354
|
+
var onChangeMode = function (e, editor) {
|
|
2067
2355
|
loadSnippetsForMode(editor.session.$mode);
|
|
2068
2356
|
};
|
|
2069
|
-
|
|
2070
|
-
var loadSnippetsForMode = function(mode) {
|
|
2357
|
+
var loadSnippetsForMode = function (mode) {
|
|
2071
2358
|
if (typeof mode == "string")
|
|
2072
2359
|
mode = config.$modes[mode];
|
|
2073
2360
|
if (!mode)
|
|
2074
2361
|
return;
|
|
2075
2362
|
if (!snippetManager.files)
|
|
2076
2363
|
snippetManager.files = {};
|
|
2077
|
-
|
|
2078
2364
|
loadSnippetFile(mode.$id, mode.snippetFileId);
|
|
2079
2365
|
if (mode.modes)
|
|
2080
2366
|
mode.modes.forEach(loadSnippetsForMode);
|
|
2081
2367
|
};
|
|
2082
|
-
|
|
2083
|
-
var loadSnippetFile = function(id, snippetFilePath) {
|
|
2368
|
+
var loadSnippetFile = function (id, snippetFilePath) {
|
|
2084
2369
|
if (!snippetFilePath || !id || snippetManager.files[id])
|
|
2085
2370
|
return;
|
|
2086
2371
|
snippetManager.files[id] = {};
|
|
2087
|
-
config.loadModule(snippetFilePath, function(m) {
|
|
2088
|
-
if (!m)
|
|
2372
|
+
config.loadModule(snippetFilePath, function (m) {
|
|
2373
|
+
if (!m)
|
|
2374
|
+
return;
|
|
2089
2375
|
snippetManager.files[id] = m;
|
|
2090
2376
|
if (!m.snippets && m.snippetText)
|
|
2091
2377
|
m.snippets = snippetManager.parseSnippetFile(m.snippetText);
|
|
2092
2378
|
snippetManager.register(m.snippets || [], m.scope);
|
|
2093
2379
|
if (m.includeScopes) {
|
|
2094
2380
|
snippetManager.snippetMap[m.scope].includeScopes = m.includeScopes;
|
|
2095
|
-
m.includeScopes.forEach(function(x) {
|
|
2381
|
+
m.includeScopes.forEach(function (x) {
|
|
2096
2382
|
loadSnippetsForMode("ace/mode/" + x);
|
|
2097
2383
|
});
|
|
2098
2384
|
}
|
|
2099
2385
|
});
|
|
2100
2386
|
};
|
|
2101
|
-
|
|
2102
|
-
var doLiveAutocomplete = function(e) {
|
|
2387
|
+
var doLiveAutocomplete = function (e) {
|
|
2103
2388
|
var editor = e.editor;
|
|
2104
2389
|
var hasCompleter = editor.completer && editor.completer.activated;
|
|
2105
2390
|
if (e.command.name === "backspace") {
|
|
2106
2391
|
if (hasCompleter && !util.getCompletionPrefix(editor))
|
|
2107
2392
|
editor.completer.detach();
|
|
2108
2393
|
}
|
|
2109
|
-
else if (e.command.name === "insertstring") {
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2394
|
+
else if (e.command.name === "insertstring" && !hasCompleter) {
|
|
2395
|
+
lastExecEvent = e;
|
|
2396
|
+
var delay = e.editor.$liveAutocompletionDelay;
|
|
2397
|
+
if (delay) {
|
|
2398
|
+
liveAutocompleteTimer.delay(delay);
|
|
2399
|
+
}
|
|
2400
|
+
else {
|
|
2401
|
+
showLiveAutocomplete(e);
|
|
2115
2402
|
}
|
|
2116
2403
|
}
|
|
2117
2404
|
};
|
|
2118
|
-
|
|
2405
|
+
var lastExecEvent;
|
|
2406
|
+
var liveAutocompleteTimer = lang.delayedCall(function () {
|
|
2407
|
+
showLiveAutocomplete(lastExecEvent);
|
|
2408
|
+
}, 0);
|
|
2409
|
+
var showLiveAutocomplete = function (e) {
|
|
2410
|
+
var editor = e.editor;
|
|
2411
|
+
var prefix = util.getCompletionPrefix(editor);
|
|
2412
|
+
var triggerAutocomplete = util.triggerAutocomplete(editor);
|
|
2413
|
+
if (prefix && prefix.length >= editor.$liveAutocompletionThreshold || triggerAutocomplete) {
|
|
2414
|
+
var completer = Autocomplete.for(editor);
|
|
2415
|
+
completer.autoShown = true;
|
|
2416
|
+
completer.showPopup(editor);
|
|
2417
|
+
}
|
|
2418
|
+
};
|
|
2119
2419
|
var Editor = require("../editor").Editor;
|
|
2120
2420
|
require("../config").defineOptions(Editor.prototype, "editor", {
|
|
2121
2421
|
enableBasicAutocompletion: {
|
|
2122
|
-
set: function(val) {
|
|
2422
|
+
set: function (val) {
|
|
2123
2423
|
if (val) {
|
|
2124
2424
|
if (!this.completers)
|
|
2125
|
-
this.completers = Array.isArray(val)? val: completers;
|
|
2425
|
+
this.completers = Array.isArray(val) ? val : completers;
|
|
2126
2426
|
this.commands.addCommand(Autocomplete.startCommand);
|
|
2127
|
-
}
|
|
2427
|
+
}
|
|
2428
|
+
else {
|
|
2128
2429
|
this.commands.removeCommand(Autocomplete.startCommand);
|
|
2129
2430
|
}
|
|
2130
2431
|
},
|
|
2131
2432
|
value: false
|
|
2132
2433
|
},
|
|
2133
2434
|
enableLiveAutocompletion: {
|
|
2134
|
-
set: function(val) {
|
|
2435
|
+
set: function (val) {
|
|
2135
2436
|
if (val) {
|
|
2136
2437
|
if (!this.completers)
|
|
2137
|
-
this.completers = Array.isArray(val)? val: completers;
|
|
2438
|
+
this.completers = Array.isArray(val) ? val : completers;
|
|
2138
2439
|
this.commands.on('afterExec', doLiveAutocomplete);
|
|
2139
|
-
}
|
|
2140
|
-
|
|
2440
|
+
}
|
|
2441
|
+
else {
|
|
2442
|
+
this.commands.off('afterExec', doLiveAutocomplete);
|
|
2141
2443
|
}
|
|
2142
2444
|
},
|
|
2143
2445
|
value: false
|
|
2144
2446
|
},
|
|
2447
|
+
liveAutocompletionDelay: {
|
|
2448
|
+
initialValue: 0
|
|
2449
|
+
},
|
|
2450
|
+
liveAutocompletionThreshold: {
|
|
2451
|
+
initialValue: 0
|
|
2452
|
+
},
|
|
2145
2453
|
enableSnippets: {
|
|
2146
|
-
set: function(val) {
|
|
2454
|
+
set: function (val) {
|
|
2147
2455
|
if (val) {
|
|
2148
2456
|
this.commands.addCommand(expandSnippet);
|
|
2149
2457
|
this.on("changeMode", onChangeMode);
|
|
2150
2458
|
onChangeMode(null, this);
|
|
2151
|
-
}
|
|
2459
|
+
}
|
|
2460
|
+
else {
|
|
2152
2461
|
this.commands.removeCommand(expandSnippet);
|
|
2153
2462
|
this.off("changeMode", onChangeMode);
|
|
2154
2463
|
}
|
|
@@ -2156,6 +2465,7 @@ require("../config").defineOptions(Editor.prototype, "editor", {
|
|
|
2156
2465
|
value: false
|
|
2157
2466
|
}
|
|
2158
2467
|
});
|
|
2468
|
+
|
|
2159
2469
|
}); (function() {
|
|
2160
2470
|
ace.require(["ace/ext/language_tools"], function(m) {
|
|
2161
2471
|
if (typeof module == "object" && typeof exports == "object" && module) {
|