rails_db 2.1.0 → 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/app/assets/javascripts/codemirror/codemirror.js +9762 -0
- data/app/assets/javascripts/codemirror/codemirror/addons/comment/comment.js +209 -0
- data/app/assets/javascripts/codemirror/codemirror/addons/comment/continuecomment.js +78 -0
- data/app/assets/javascripts/codemirror/codemirror/addons/dialog/dialog.js +161 -0
- data/app/assets/javascripts/codemirror/codemirror/addons/display/autorefresh.js +47 -0
- data/app/assets/javascripts/codemirror/codemirror/addons/display/fullscreen.js +41 -0
- data/app/assets/javascripts/codemirror/codemirror/addons/display/panel.js +127 -0
- data/app/assets/javascripts/codemirror/codemirror/addons/display/placeholder.js +63 -0
- data/app/assets/javascripts/codemirror/codemirror/addons/display/rulers.js +51 -0
- data/app/assets/javascripts/codemirror/codemirror/addons/edit/closebrackets.js +191 -0
- data/app/assets/javascripts/codemirror/codemirror/addons/edit/closetag.js +183 -0
- data/app/assets/javascripts/codemirror/codemirror/addons/edit/continuelist.js +99 -0
- data/app/assets/javascripts/codemirror/codemirror/addons/edit/matchbrackets.js +150 -0
- data/app/assets/javascripts/codemirror/codemirror/addons/edit/matchtags.js +66 -0
- data/app/assets/javascripts/codemirror/codemirror/addons/edit/trailingspace.js +27 -0
- data/app/assets/javascripts/codemirror/codemirror/addons/fold/brace-fold.js +105 -0
- data/app/assets/javascripts/codemirror/codemirror/addons/fold/comment-fold.js +59 -0
- data/app/assets/javascripts/codemirror/codemirror/addons/fold/foldcode.js +152 -0
- data/app/assets/javascripts/codemirror/codemirror/addons/fold/foldgutter.js +146 -0
- data/app/assets/javascripts/codemirror/codemirror/addons/fold/indent-fold.js +48 -0
- data/app/assets/javascripts/codemirror/codemirror/addons/fold/markdown-fold.js +49 -0
- data/app/assets/javascripts/codemirror/codemirror/addons/fold/xml-fold.js +184 -0
- data/app/assets/javascripts/codemirror/codemirror/addons/hint/anyword-hint.js +41 -0
- data/app/assets/javascripts/codemirror/codemirror/addons/hint/css-hint.js +60 -0
- data/app/assets/javascripts/codemirror/codemirror/addons/hint/html-hint.js +350 -0
- data/app/assets/javascripts/codemirror/codemirror/addons/hint/javascript-hint.js +157 -0
- data/app/assets/javascripts/codemirror/codemirror/addons/hint/show-hint.js +460 -0
- data/app/assets/javascripts/codemirror/codemirror/addons/hint/sql-hint.js +304 -0
- data/app/assets/javascripts/codemirror/codemirror/addons/hint/xml-hint.js +120 -0
- data/app/assets/javascripts/codemirror/codemirror/addons/lint/coffeescript-lint.js +47 -0
- data/app/assets/javascripts/codemirror/codemirror/addons/lint/css-lint.js +40 -0
- data/app/assets/javascripts/codemirror/codemirror/addons/lint/html-lint.js +59 -0
- data/app/assets/javascripts/codemirror/codemirror/addons/lint/javascript-lint.js +63 -0
- data/app/assets/javascripts/codemirror/codemirror/addons/lint/json-lint.js +40 -0
- data/app/assets/javascripts/codemirror/codemirror/addons/lint/lint.js +252 -0
- data/app/assets/javascripts/codemirror/codemirror/addons/lint/yaml-lint.js +41 -0
- data/app/assets/javascripts/codemirror/codemirror/addons/merge/merge.js +1002 -0
- data/app/assets/javascripts/codemirror/codemirror/addons/mode/loadmode.js +64 -0
- data/app/assets/javascripts/codemirror/codemirror/addons/mode/multiplex.js +131 -0
- data/app/assets/javascripts/codemirror/codemirror/addons/mode/multiplex_test.js +33 -0
- data/app/assets/javascripts/codemirror/codemirror/addons/mode/overlay.js +90 -0
- data/app/assets/javascripts/codemirror/codemirror/addons/mode/simple.js +216 -0
- data/app/assets/javascripts/codemirror/codemirror/addons/runmode/colorize.js +40 -0
- data/app/assets/javascripts/codemirror/codemirror/addons/runmode/runmode-standalone.js +158 -0
- data/app/assets/javascripts/codemirror/codemirror/addons/runmode/runmode.js +72 -0
- data/app/assets/javascripts/codemirror/codemirror/addons/runmode/runmode.node.js +197 -0
- data/app/assets/javascripts/codemirror/codemirror/addons/scroll/annotatescrollbar.js +122 -0
- data/app/assets/javascripts/codemirror/codemirror/addons/scroll/scrollpastend.js +48 -0
- data/app/assets/javascripts/codemirror/codemirror/addons/scroll/simplescrollbars.js +152 -0
- data/app/assets/javascripts/codemirror/codemirror/addons/search/jump-to-line.js +50 -0
- data/app/assets/javascripts/codemirror/codemirror/addons/search/match-highlighter.js +165 -0
- data/app/assets/javascripts/codemirror/codemirror/addons/search/matchesonscrollbar.js +97 -0
- data/app/assets/javascripts/codemirror/codemirror/addons/search/search.js +260 -0
- data/app/assets/javascripts/codemirror/codemirror/addons/search/searchcursor.js +293 -0
- data/app/assets/javascripts/codemirror/codemirror/addons/selection/active-line.js +72 -0
- data/app/assets/javascripts/codemirror/codemirror/addons/selection/mark-selection.js +119 -0
- data/app/assets/javascripts/codemirror/codemirror/addons/selection/selection-pointer.js +98 -0
- data/app/assets/javascripts/codemirror/codemirror/addons/tern/tern.js +718 -0
- data/app/assets/javascripts/codemirror/codemirror/addons/tern/worker.js +44 -0
- data/app/assets/javascripts/codemirror/codemirror/addons/wrap/hardwrap.js +145 -0
- data/app/assets/javascripts/codemirror/codemirror/keymaps/emacs.js +418 -0
- data/app/assets/javascripts/codemirror/codemirror/keymaps/sublime.js +691 -0
- data/app/assets/javascripts/codemirror/codemirror/keymaps/vim.js +5494 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/apl.js +174 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/asciiarmor.js +74 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/asn.1.js +204 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/asterisk.js +196 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/brainfuck.js +85 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/clike.js +884 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/clojure.js +292 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/cmake.js +97 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/cobol.js +255 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/coffeescript.js +359 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/commonlisp.js +124 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/crystal.js +433 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/css.js +831 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/cypher.js +150 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/d.js +223 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/dart.js +157 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/diff.js +47 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/django.js +356 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/dockerfile.js +211 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/dtd.js +142 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/dylan.js +352 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/ebnf.js +195 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/ecl.js +206 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/eiffel.js +160 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/elm.js +205 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/erlang.js +619 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/factor.js +85 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/fcl.js +173 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/forth.js +180 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/fortran.js +188 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/gas.js +345 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/gfm.js +129 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/gherkin.js +178 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/go.js +187 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/groovy.js +233 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/haml.js +161 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/handlebars.js +66 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/haskell-literate.js +43 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/haskell.js +268 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/haxe.js +515 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/htmlembedded.js +37 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/htmlmixed.js +152 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/http.js +113 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/idl.js +290 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/jade.js +590 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/javascript.js +927 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/jinja2.js +146 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/jsx.js +148 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/julia.js +431 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/livescript.js +280 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/lua.js +159 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/markdown.js +884 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/mathematica.js +176 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/mbox.js +129 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/meta.js +218 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/mirc.js +193 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/mllike.js +359 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/modelica.js +245 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/mscgen.js +175 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/mumps.js +148 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/nginx.js +178 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/nsis.js +95 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/ntriples.js +195 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/octave.js +139 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/oz.js +252 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/pascal.js +121 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/pegjs.js +114 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/perl.js +837 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/php.js +234 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/pig.js +178 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/powershell.js +398 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/properties.js +78 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/protobuf.js +69 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/pug.js +591 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/puppet.js +220 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/python.js +399 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/q.js +139 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/r.js +190 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/rpm.js +109 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/rst.js +557 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/ruby.js +298 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/rust.js +72 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/sas.js +303 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/sass.js +454 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/scheme.js +265 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/shell.js +152 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/sieve.js +193 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/slim.js +575 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/smalltalk.js +168 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/smarty.js +225 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/solr.js +104 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/soy.js +435 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/sparql.js +180 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/spreadsheet.js +112 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/sql.js +494 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/stex.js +264 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/stylus.js +771 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/swift.js +223 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/tcl.js +139 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/textile.js +469 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/tiddlywiki.js +308 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/tiki.js +312 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/toml.js +88 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/tornado.js +68 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/troff.js +84 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/ttcn-cfg.js +214 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/ttcn.js +283 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/turtle.js +162 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/twig.js +141 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/vb.js +275 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/vbscript.js +350 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/velocity.js +201 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/verilog.js +675 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/vhdl.js +189 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/vue.js +77 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/webidl.js +195 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/xml.js +402 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/xquery.js +448 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/yacas.js +204 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/yaml-frontmatter.js +68 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/yaml.js +120 -0
- data/app/assets/javascripts/codemirror/codemirror/modes/z80.js +116 -0
- data/app/assets/javascripts/rails_db/application.js +4 -4
- data/app/assets/stylesheets/codemirror/codemirror.css +346 -0
- data/app/assets/stylesheets/codemirror/codemirror/addons/dialog/dialog.css +32 -0
- data/app/assets/stylesheets/codemirror/codemirror/addons/display/fullscreen.css +6 -0
- data/app/assets/stylesheets/codemirror/codemirror/addons/fold/foldgutter.css +20 -0
- data/app/assets/stylesheets/codemirror/codemirror/addons/hint/show-hint.css +36 -0
- data/app/assets/stylesheets/codemirror/codemirror/addons/lint/lint.css +73 -0
- data/app/assets/stylesheets/codemirror/codemirror/addons/merge/merge.css +119 -0
- data/app/assets/stylesheets/codemirror/codemirror/addons/scroll/simplescrollbars.css +66 -0
- data/app/assets/stylesheets/codemirror/codemirror/addons/search/matchesonscrollbar.css +8 -0
- data/app/assets/stylesheets/codemirror/codemirror/addons/tern/tern.css +87 -0
- data/app/assets/stylesheets/codemirror/codemirror/modes/tiddlywiki.css +14 -0
- data/app/assets/stylesheets/codemirror/codemirror/modes/tiki.css +26 -0
- data/app/assets/stylesheets/codemirror/codemirror/themes/3024-day.css +41 -0
- data/app/assets/stylesheets/codemirror/codemirror/themes/3024-night.css +39 -0
- data/app/assets/stylesheets/codemirror/codemirror/themes/abcdef.css +32 -0
- data/app/assets/stylesheets/codemirror/codemirror/themes/ambiance-mobile.css +5 -0
- data/app/assets/stylesheets/codemirror/codemirror/themes/ambiance.css +74 -0
- data/app/assets/stylesheets/codemirror/codemirror/themes/base16-dark.css +38 -0
- data/app/assets/stylesheets/codemirror/codemirror/themes/base16-light.css +38 -0
- data/app/assets/stylesheets/codemirror/codemirror/themes/bespin.css +34 -0
- data/app/assets/stylesheets/codemirror/codemirror/themes/blackboard.css +32 -0
- data/app/assets/stylesheets/codemirror/codemirror/themes/cobalt.css +25 -0
- data/app/assets/stylesheets/codemirror/codemirror/themes/colorforth.css +33 -0
- data/app/assets/stylesheets/codemirror/codemirror/themes/darcula.css +51 -0
- data/app/assets/stylesheets/codemirror/codemirror/themes/dracula.css +40 -0
- data/app/assets/stylesheets/codemirror/codemirror/themes/duotone-dark.css +35 -0
- data/app/assets/stylesheets/codemirror/codemirror/themes/duotone-light.css +36 -0
- data/app/assets/stylesheets/codemirror/codemirror/themes/eclipse.css +23 -0
- data/app/assets/stylesheets/codemirror/codemirror/themes/elegant.css +13 -0
- data/app/assets/stylesheets/codemirror/codemirror/themes/erlang-dark.css +34 -0
- data/app/assets/stylesheets/codemirror/codemirror/themes/gruvbox-dark.css +37 -0
- data/app/assets/stylesheets/codemirror/codemirror/themes/hopscotch.css +34 -0
- data/app/assets/stylesheets/codemirror/codemirror/themes/icecoder.css +43 -0
- data/app/assets/stylesheets/codemirror/codemirror/themes/idea.css +42 -0
- data/app/assets/stylesheets/codemirror/codemirror/themes/isotope.css +34 -0
- data/app/assets/stylesheets/codemirror/codemirror/themes/lesser-dark.css +47 -0
- data/app/assets/stylesheets/codemirror/codemirror/themes/liquibyte.css +95 -0
- data/app/assets/stylesheets/codemirror/codemirror/themes/lucario.css +37 -0
- data/app/assets/stylesheets/codemirror/codemirror/themes/material.css +53 -0
- data/app/assets/stylesheets/codemirror/codemirror/themes/mbo.css +37 -0
- data/app/assets/stylesheets/codemirror/codemirror/themes/mdn-like.css +46 -0
- data/app/assets/stylesheets/codemirror/codemirror/themes/midnight.css +39 -0
- data/app/assets/stylesheets/codemirror/codemirror/themes/monokai.css +41 -0
- data/app/assets/stylesheets/codemirror/codemirror/themes/neat.css +12 -0
- data/app/assets/stylesheets/codemirror/codemirror/themes/neo.css +43 -0
- data/app/assets/stylesheets/codemirror/codemirror/themes/night.css +27 -0
- data/app/assets/stylesheets/codemirror/codemirror/themes/nord.css +42 -0
- data/app/assets/stylesheets/codemirror/codemirror/themes/oceanic-next.css +44 -0
- data/app/assets/stylesheets/codemirror/codemirror/themes/panda-syntax.css +85 -0
- data/app/assets/stylesheets/codemirror/codemirror/themes/paraiso-dark.css +38 -0
- data/app/assets/stylesheets/codemirror/codemirror/themes/paraiso-light.css +38 -0
- data/app/assets/stylesheets/codemirror/codemirror/themes/pastel-on-dark.css +52 -0
- data/app/assets/stylesheets/codemirror/codemirror/themes/railscasts.css +34 -0
- data/app/assets/stylesheets/codemirror/codemirror/themes/rubyblue.css +25 -0
- data/app/assets/stylesheets/codemirror/codemirror/themes/seti.css +44 -0
- data/app/assets/stylesheets/codemirror/codemirror/themes/shadowfox.css +52 -0
- data/app/assets/stylesheets/codemirror/codemirror/themes/solarized.css +168 -0
- data/app/assets/stylesheets/codemirror/codemirror/themes/ssms.css +16 -0
- data/app/assets/stylesheets/codemirror/codemirror/themes/the-matrix.css +30 -0
- data/app/assets/stylesheets/codemirror/codemirror/themes/tomorrow-night-bright.css +35 -0
- data/app/assets/stylesheets/codemirror/codemirror/themes/tomorrow-night-eighties.css +38 -0
- data/app/assets/stylesheets/codemirror/codemirror/themes/ttcn.css +64 -0
- data/app/assets/stylesheets/codemirror/codemirror/themes/twilight.css +32 -0
- data/app/assets/stylesheets/codemirror/codemirror/themes/vibrant-ink.css +34 -0
- data/app/assets/stylesheets/codemirror/codemirror/themes/xq-dark.css +53 -0
- data/app/assets/stylesheets/codemirror/codemirror/themes/xq-light.css +43 -0
- data/app/assets/stylesheets/codemirror/codemirror/themes/zenburn.css +37 -0
- data/app/assets/stylesheets/rails_db/application.css +3 -3
- data/lib/rails_db/engine.rb +1 -1
- data/lib/rails_db/version.rb +1 -1
- metadata +253 -1
@@ -0,0 +1,927 @@
|
|
1
|
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2
|
+
// Distributed under an MIT license: https://codemirror.net/LICENSE
|
3
|
+
|
4
|
+
(function(mod) {
|
5
|
+
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6
|
+
mod(require("../../lib/codemirror"));
|
7
|
+
else if (typeof define == "function" && define.amd) // AMD
|
8
|
+
define(["../../lib/codemirror"], mod);
|
9
|
+
else // Plain browser env
|
10
|
+
mod(CodeMirror);
|
11
|
+
})(function(CodeMirror) {
|
12
|
+
"use strict";
|
13
|
+
|
14
|
+
CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
15
|
+
var indentUnit = config.indentUnit;
|
16
|
+
var statementIndent = parserConfig.statementIndent;
|
17
|
+
var jsonldMode = parserConfig.jsonld;
|
18
|
+
var jsonMode = parserConfig.json || jsonldMode;
|
19
|
+
var isTS = parserConfig.typescript;
|
20
|
+
var wordRE = parserConfig.wordCharacters || /[\w$\xa1-\uffff]/;
|
21
|
+
|
22
|
+
// Tokenizer
|
23
|
+
|
24
|
+
var keywords = function(){
|
25
|
+
function kw(type) {return {type: type, style: "keyword"};}
|
26
|
+
var A = kw("keyword a"), B = kw("keyword b"), C = kw("keyword c"), D = kw("keyword d");
|
27
|
+
var operator = kw("operator"), atom = {type: "atom", style: "atom"};
|
28
|
+
|
29
|
+
return {
|
30
|
+
"if": kw("if"), "while": A, "with": A, "else": B, "do": B, "try": B, "finally": B,
|
31
|
+
"return": D, "break": D, "continue": D, "new": kw("new"), "delete": C, "void": C, "throw": C,
|
32
|
+
"debugger": kw("debugger"), "var": kw("var"), "const": kw("var"), "let": kw("var"),
|
33
|
+
"function": kw("function"), "catch": kw("catch"),
|
34
|
+
"for": kw("for"), "switch": kw("switch"), "case": kw("case"), "default": kw("default"),
|
35
|
+
"in": operator, "typeof": operator, "instanceof": operator,
|
36
|
+
"true": atom, "false": atom, "null": atom, "undefined": atom, "NaN": atom, "Infinity": atom,
|
37
|
+
"this": kw("this"), "class": kw("class"), "super": kw("atom"),
|
38
|
+
"yield": C, "export": kw("export"), "import": kw("import"), "extends": C,
|
39
|
+
"await": C
|
40
|
+
};
|
41
|
+
}();
|
42
|
+
|
43
|
+
var isOperatorChar = /[+\-*&%=<>!?|~^@]/;
|
44
|
+
var isJsonldKeyword = /^@(context|id|value|language|type|container|list|set|reverse|index|base|vocab|graph)"/;
|
45
|
+
|
46
|
+
function readRegexp(stream) {
|
47
|
+
var escaped = false, next, inSet = false;
|
48
|
+
while ((next = stream.next()) != null) {
|
49
|
+
if (!escaped) {
|
50
|
+
if (next == "/" && !inSet) return;
|
51
|
+
if (next == "[") inSet = true;
|
52
|
+
else if (inSet && next == "]") inSet = false;
|
53
|
+
}
|
54
|
+
escaped = !escaped && next == "\\";
|
55
|
+
}
|
56
|
+
}
|
57
|
+
|
58
|
+
// Used as scratch variables to communicate multiple values without
|
59
|
+
// consing up tons of objects.
|
60
|
+
var type, content;
|
61
|
+
function ret(tp, style, cont) {
|
62
|
+
type = tp; content = cont;
|
63
|
+
return style;
|
64
|
+
}
|
65
|
+
function tokenBase(stream, state) {
|
66
|
+
var ch = stream.next();
|
67
|
+
if (ch == '"' || ch == "'") {
|
68
|
+
state.tokenize = tokenString(ch);
|
69
|
+
return state.tokenize(stream, state);
|
70
|
+
} else if (ch == "." && stream.match(/^\d[\d_]*(?:[eE][+\-]?[\d_]+)?/)) {
|
71
|
+
return ret("number", "number");
|
72
|
+
} else if (ch == "." && stream.match("..")) {
|
73
|
+
return ret("spread", "meta");
|
74
|
+
} else if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
|
75
|
+
return ret(ch);
|
76
|
+
} else if (ch == "=" && stream.eat(">")) {
|
77
|
+
return ret("=>", "operator");
|
78
|
+
} else if (ch == "0" && stream.match(/^(?:x[\dA-Fa-f_]+|o[0-7_]+|b[01_]+)n?/)) {
|
79
|
+
return ret("number", "number");
|
80
|
+
} else if (/\d/.test(ch)) {
|
81
|
+
stream.match(/^[\d_]*(?:n|(?:\.[\d_]*)?(?:[eE][+\-]?[\d_]+)?)?/);
|
82
|
+
return ret("number", "number");
|
83
|
+
} else if (ch == "/") {
|
84
|
+
if (stream.eat("*")) {
|
85
|
+
state.tokenize = tokenComment;
|
86
|
+
return tokenComment(stream, state);
|
87
|
+
} else if (stream.eat("/")) {
|
88
|
+
stream.skipToEnd();
|
89
|
+
return ret("comment", "comment");
|
90
|
+
} else if (expressionAllowed(stream, state, 1)) {
|
91
|
+
readRegexp(stream);
|
92
|
+
stream.match(/^\b(([gimyus])(?![gimyus]*\2))+\b/);
|
93
|
+
return ret("regexp", "string-2");
|
94
|
+
} else {
|
95
|
+
stream.eat("=");
|
96
|
+
return ret("operator", "operator", stream.current());
|
97
|
+
}
|
98
|
+
} else if (ch == "`") {
|
99
|
+
state.tokenize = tokenQuasi;
|
100
|
+
return tokenQuasi(stream, state);
|
101
|
+
} else if (ch == "#") {
|
102
|
+
stream.skipToEnd();
|
103
|
+
return ret("error", "error");
|
104
|
+
} else if (isOperatorChar.test(ch)) {
|
105
|
+
if (ch != ">" || !state.lexical || state.lexical.type != ">") {
|
106
|
+
if (stream.eat("=")) {
|
107
|
+
if (ch == "!" || ch == "=") stream.eat("=")
|
108
|
+
} else if (/[<>*+\-]/.test(ch)) {
|
109
|
+
stream.eat(ch)
|
110
|
+
if (ch == ">") stream.eat(ch)
|
111
|
+
}
|
112
|
+
}
|
113
|
+
return ret("operator", "operator", stream.current());
|
114
|
+
} else if (wordRE.test(ch)) {
|
115
|
+
stream.eatWhile(wordRE);
|
116
|
+
var word = stream.current()
|
117
|
+
if (state.lastType != ".") {
|
118
|
+
if (keywords.propertyIsEnumerable(word)) {
|
119
|
+
var kw = keywords[word]
|
120
|
+
return ret(kw.type, kw.style, word)
|
121
|
+
}
|
122
|
+
if (word == "async" && stream.match(/^(\s|\/\*.*?\*\/)*[\[\(\w]/, false))
|
123
|
+
return ret("async", "keyword", word)
|
124
|
+
}
|
125
|
+
return ret("variable", "variable", word)
|
126
|
+
}
|
127
|
+
}
|
128
|
+
|
129
|
+
function tokenString(quote) {
|
130
|
+
return function(stream, state) {
|
131
|
+
var escaped = false, next;
|
132
|
+
if (jsonldMode && stream.peek() == "@" && stream.match(isJsonldKeyword)){
|
133
|
+
state.tokenize = tokenBase;
|
134
|
+
return ret("jsonld-keyword", "meta");
|
135
|
+
}
|
136
|
+
while ((next = stream.next()) != null) {
|
137
|
+
if (next == quote && !escaped) break;
|
138
|
+
escaped = !escaped && next == "\\";
|
139
|
+
}
|
140
|
+
if (!escaped) state.tokenize = tokenBase;
|
141
|
+
return ret("string", "string");
|
142
|
+
};
|
143
|
+
}
|
144
|
+
|
145
|
+
function tokenComment(stream, state) {
|
146
|
+
var maybeEnd = false, ch;
|
147
|
+
while (ch = stream.next()) {
|
148
|
+
if (ch == "/" && maybeEnd) {
|
149
|
+
state.tokenize = tokenBase;
|
150
|
+
break;
|
151
|
+
}
|
152
|
+
maybeEnd = (ch == "*");
|
153
|
+
}
|
154
|
+
return ret("comment", "comment");
|
155
|
+
}
|
156
|
+
|
157
|
+
function tokenQuasi(stream, state) {
|
158
|
+
var escaped = false, next;
|
159
|
+
while ((next = stream.next()) != null) {
|
160
|
+
if (!escaped && (next == "`" || next == "$" && stream.eat("{"))) {
|
161
|
+
state.tokenize = tokenBase;
|
162
|
+
break;
|
163
|
+
}
|
164
|
+
escaped = !escaped && next == "\\";
|
165
|
+
}
|
166
|
+
return ret("quasi", "string-2", stream.current());
|
167
|
+
}
|
168
|
+
|
169
|
+
var brackets = "([{}])";
|
170
|
+
// This is a crude lookahead trick to try and notice that we're
|
171
|
+
// parsing the argument patterns for a fat-arrow function before we
|
172
|
+
// actually hit the arrow token. It only works if the arrow is on
|
173
|
+
// the same line as the arguments and there's no strange noise
|
174
|
+
// (comments) in between. Fallback is to only notice when we hit the
|
175
|
+
// arrow, and not declare the arguments as locals for the arrow
|
176
|
+
// body.
|
177
|
+
function findFatArrow(stream, state) {
|
178
|
+
if (state.fatArrowAt) state.fatArrowAt = null;
|
179
|
+
var arrow = stream.string.indexOf("=>", stream.start);
|
180
|
+
if (arrow < 0) return;
|
181
|
+
|
182
|
+
if (isTS) { // Try to skip TypeScript return type declarations after the arguments
|
183
|
+
var m = /:\s*(?:\w+(?:<[^>]*>|\[\])?|\{[^}]*\})\s*$/.exec(stream.string.slice(stream.start, arrow))
|
184
|
+
if (m) arrow = m.index
|
185
|
+
}
|
186
|
+
|
187
|
+
var depth = 0, sawSomething = false;
|
188
|
+
for (var pos = arrow - 1; pos >= 0; --pos) {
|
189
|
+
var ch = stream.string.charAt(pos);
|
190
|
+
var bracket = brackets.indexOf(ch);
|
191
|
+
if (bracket >= 0 && bracket < 3) {
|
192
|
+
if (!depth) { ++pos; break; }
|
193
|
+
if (--depth == 0) { if (ch == "(") sawSomething = true; break; }
|
194
|
+
} else if (bracket >= 3 && bracket < 6) {
|
195
|
+
++depth;
|
196
|
+
} else if (wordRE.test(ch)) {
|
197
|
+
sawSomething = true;
|
198
|
+
} else if (/["'\/`]/.test(ch)) {
|
199
|
+
for (;; --pos) {
|
200
|
+
if (pos == 0) return
|
201
|
+
var next = stream.string.charAt(pos - 1)
|
202
|
+
if (next == ch && stream.string.charAt(pos - 2) != "\\") { pos--; break }
|
203
|
+
}
|
204
|
+
} else if (sawSomething && !depth) {
|
205
|
+
++pos;
|
206
|
+
break;
|
207
|
+
}
|
208
|
+
}
|
209
|
+
if (sawSomething && !depth) state.fatArrowAt = pos;
|
210
|
+
}
|
211
|
+
|
212
|
+
// Parser
|
213
|
+
|
214
|
+
var atomicTypes = {"atom": true, "number": true, "variable": true, "string": true, "regexp": true, "this": true, "jsonld-keyword": true};
|
215
|
+
|
216
|
+
function JSLexical(indented, column, type, align, prev, info) {
|
217
|
+
this.indented = indented;
|
218
|
+
this.column = column;
|
219
|
+
this.type = type;
|
220
|
+
this.prev = prev;
|
221
|
+
this.info = info;
|
222
|
+
if (align != null) this.align = align;
|
223
|
+
}
|
224
|
+
|
225
|
+
function inScope(state, varname) {
|
226
|
+
for (var v = state.localVars; v; v = v.next)
|
227
|
+
if (v.name == varname) return true;
|
228
|
+
for (var cx = state.context; cx; cx = cx.prev) {
|
229
|
+
for (var v = cx.vars; v; v = v.next)
|
230
|
+
if (v.name == varname) return true;
|
231
|
+
}
|
232
|
+
}
|
233
|
+
|
234
|
+
function parseJS(state, style, type, content, stream) {
|
235
|
+
var cc = state.cc;
|
236
|
+
// Communicate our context to the combinators.
|
237
|
+
// (Less wasteful than consing up a hundred closures on every call.)
|
238
|
+
cx.state = state; cx.stream = stream; cx.marked = null, cx.cc = cc; cx.style = style;
|
239
|
+
|
240
|
+
if (!state.lexical.hasOwnProperty("align"))
|
241
|
+
state.lexical.align = true;
|
242
|
+
|
243
|
+
while(true) {
|
244
|
+
var combinator = cc.length ? cc.pop() : jsonMode ? expression : statement;
|
245
|
+
if (combinator(type, content)) {
|
246
|
+
while(cc.length && cc[cc.length - 1].lex)
|
247
|
+
cc.pop()();
|
248
|
+
if (cx.marked) return cx.marked;
|
249
|
+
if (type == "variable" && inScope(state, content)) return "variable-2";
|
250
|
+
return style;
|
251
|
+
}
|
252
|
+
}
|
253
|
+
}
|
254
|
+
|
255
|
+
// Combinator utils
|
256
|
+
|
257
|
+
var cx = {state: null, column: null, marked: null, cc: null};
|
258
|
+
function pass() {
|
259
|
+
for (var i = arguments.length - 1; i >= 0; i--) cx.cc.push(arguments[i]);
|
260
|
+
}
|
261
|
+
function cont() {
|
262
|
+
pass.apply(null, arguments);
|
263
|
+
return true;
|
264
|
+
}
|
265
|
+
function inList(name, list) {
|
266
|
+
for (var v = list; v; v = v.next) if (v.name == name) return true
|
267
|
+
return false;
|
268
|
+
}
|
269
|
+
function register(varname) {
|
270
|
+
var state = cx.state;
|
271
|
+
cx.marked = "def";
|
272
|
+
if (state.context) {
|
273
|
+
if (state.lexical.info == "var" && state.context && state.context.block) {
|
274
|
+
// FIXME function decls are also not block scoped
|
275
|
+
var newContext = registerVarScoped(varname, state.context)
|
276
|
+
if (newContext != null) {
|
277
|
+
state.context = newContext
|
278
|
+
return
|
279
|
+
}
|
280
|
+
} else if (!inList(varname, state.localVars)) {
|
281
|
+
state.localVars = new Var(varname, state.localVars)
|
282
|
+
return
|
283
|
+
}
|
284
|
+
}
|
285
|
+
// Fall through means this is global
|
286
|
+
if (parserConfig.globalVars && !inList(varname, state.globalVars))
|
287
|
+
state.globalVars = new Var(varname, state.globalVars)
|
288
|
+
}
|
289
|
+
function registerVarScoped(varname, context) {
|
290
|
+
if (!context) {
|
291
|
+
return null
|
292
|
+
} else if (context.block) {
|
293
|
+
var inner = registerVarScoped(varname, context.prev)
|
294
|
+
if (!inner) return null
|
295
|
+
if (inner == context.prev) return context
|
296
|
+
return new Context(inner, context.vars, true)
|
297
|
+
} else if (inList(varname, context.vars)) {
|
298
|
+
return context
|
299
|
+
} else {
|
300
|
+
return new Context(context.prev, new Var(varname, context.vars), false)
|
301
|
+
}
|
302
|
+
}
|
303
|
+
|
304
|
+
function isModifier(name) {
|
305
|
+
return name == "public" || name == "private" || name == "protected" || name == "abstract" || name == "readonly"
|
306
|
+
}
|
307
|
+
|
308
|
+
// Combinators
|
309
|
+
|
310
|
+
function Context(prev, vars, block) { this.prev = prev; this.vars = vars; this.block = block }
|
311
|
+
function Var(name, next) { this.name = name; this.next = next }
|
312
|
+
|
313
|
+
var defaultVars = new Var("this", new Var("arguments", null))
|
314
|
+
function pushcontext() {
|
315
|
+
cx.state.context = new Context(cx.state.context, cx.state.localVars, false)
|
316
|
+
cx.state.localVars = defaultVars
|
317
|
+
}
|
318
|
+
function pushblockcontext() {
|
319
|
+
cx.state.context = new Context(cx.state.context, cx.state.localVars, true)
|
320
|
+
cx.state.localVars = null
|
321
|
+
}
|
322
|
+
function popcontext() {
|
323
|
+
cx.state.localVars = cx.state.context.vars
|
324
|
+
cx.state.context = cx.state.context.prev
|
325
|
+
}
|
326
|
+
popcontext.lex = true
|
327
|
+
function pushlex(type, info) {
|
328
|
+
var result = function() {
|
329
|
+
var state = cx.state, indent = state.indented;
|
330
|
+
if (state.lexical.type == "stat") indent = state.lexical.indented;
|
331
|
+
else for (var outer = state.lexical; outer && outer.type == ")" && outer.align; outer = outer.prev)
|
332
|
+
indent = outer.indented;
|
333
|
+
state.lexical = new JSLexical(indent, cx.stream.column(), type, null, state.lexical, info);
|
334
|
+
};
|
335
|
+
result.lex = true;
|
336
|
+
return result;
|
337
|
+
}
|
338
|
+
function poplex() {
|
339
|
+
var state = cx.state;
|
340
|
+
if (state.lexical.prev) {
|
341
|
+
if (state.lexical.type == ")")
|
342
|
+
state.indented = state.lexical.indented;
|
343
|
+
state.lexical = state.lexical.prev;
|
344
|
+
}
|
345
|
+
}
|
346
|
+
poplex.lex = true;
|
347
|
+
|
348
|
+
function expect(wanted) {
|
349
|
+
function exp(type) {
|
350
|
+
if (type == wanted) return cont();
|
351
|
+
else if (wanted == ";" || type == "}" || type == ")" || type == "]") return pass();
|
352
|
+
else return cont(exp);
|
353
|
+
};
|
354
|
+
return exp;
|
355
|
+
}
|
356
|
+
|
357
|
+
function statement(type, value) {
|
358
|
+
if (type == "var") return cont(pushlex("vardef", value), vardef, expect(";"), poplex);
|
359
|
+
if (type == "keyword a") return cont(pushlex("form"), parenExpr, statement, poplex);
|
360
|
+
if (type == "keyword b") return cont(pushlex("form"), statement, poplex);
|
361
|
+
if (type == "keyword d") return cx.stream.match(/^\s*$/, false) ? cont() : cont(pushlex("stat"), maybeexpression, expect(";"), poplex);
|
362
|
+
if (type == "debugger") return cont(expect(";"));
|
363
|
+
if (type == "{") return cont(pushlex("}"), pushblockcontext, block, poplex, popcontext);
|
364
|
+
if (type == ";") return cont();
|
365
|
+
if (type == "if") {
|
366
|
+
if (cx.state.lexical.info == "else" && cx.state.cc[cx.state.cc.length - 1] == poplex)
|
367
|
+
cx.state.cc.pop()();
|
368
|
+
return cont(pushlex("form"), parenExpr, statement, poplex, maybeelse);
|
369
|
+
}
|
370
|
+
if (type == "function") return cont(functiondef);
|
371
|
+
if (type == "for") return cont(pushlex("form"), forspec, statement, poplex);
|
372
|
+
if (type == "class" || (isTS && value == "interface")) {
|
373
|
+
cx.marked = "keyword"
|
374
|
+
return cont(pushlex("form", type == "class" ? type : value), className, poplex)
|
375
|
+
}
|
376
|
+
if (type == "variable") {
|
377
|
+
if (isTS && value == "declare") {
|
378
|
+
cx.marked = "keyword"
|
379
|
+
return cont(statement)
|
380
|
+
} else if (isTS && (value == "module" || value == "enum" || value == "type") && cx.stream.match(/^\s*\w/, false)) {
|
381
|
+
cx.marked = "keyword"
|
382
|
+
if (value == "enum") return cont(enumdef);
|
383
|
+
else if (value == "type") return cont(typename, expect("operator"), typeexpr, expect(";"));
|
384
|
+
else return cont(pushlex("form"), pattern, expect("{"), pushlex("}"), block, poplex, poplex)
|
385
|
+
} else if (isTS && value == "namespace") {
|
386
|
+
cx.marked = "keyword"
|
387
|
+
return cont(pushlex("form"), expression, statement, poplex)
|
388
|
+
} else if (isTS && value == "abstract") {
|
389
|
+
cx.marked = "keyword"
|
390
|
+
return cont(statement)
|
391
|
+
} else {
|
392
|
+
return cont(pushlex("stat"), maybelabel);
|
393
|
+
}
|
394
|
+
}
|
395
|
+
if (type == "switch") return cont(pushlex("form"), parenExpr, expect("{"), pushlex("}", "switch"), pushblockcontext,
|
396
|
+
block, poplex, poplex, popcontext);
|
397
|
+
if (type == "case") return cont(expression, expect(":"));
|
398
|
+
if (type == "default") return cont(expect(":"));
|
399
|
+
if (type == "catch") return cont(pushlex("form"), pushcontext, maybeCatchBinding, statement, poplex, popcontext);
|
400
|
+
if (type == "export") return cont(pushlex("stat"), afterExport, poplex);
|
401
|
+
if (type == "import") return cont(pushlex("stat"), afterImport, poplex);
|
402
|
+
if (type == "async") return cont(statement)
|
403
|
+
if (value == "@") return cont(expression, statement)
|
404
|
+
return pass(pushlex("stat"), expression, expect(";"), poplex);
|
405
|
+
}
|
406
|
+
function maybeCatchBinding(type) {
|
407
|
+
if (type == "(") return cont(funarg, expect(")"))
|
408
|
+
}
|
409
|
+
function expression(type, value) {
|
410
|
+
return expressionInner(type, value, false);
|
411
|
+
}
|
412
|
+
function expressionNoComma(type, value) {
|
413
|
+
return expressionInner(type, value, true);
|
414
|
+
}
|
415
|
+
function parenExpr(type) {
|
416
|
+
if (type != "(") return pass()
|
417
|
+
return cont(pushlex(")"), expression, expect(")"), poplex)
|
418
|
+
}
|
419
|
+
function expressionInner(type, value, noComma) {
|
420
|
+
if (cx.state.fatArrowAt == cx.stream.start) {
|
421
|
+
var body = noComma ? arrowBodyNoComma : arrowBody;
|
422
|
+
if (type == "(") return cont(pushcontext, pushlex(")"), commasep(funarg, ")"), poplex, expect("=>"), body, popcontext);
|
423
|
+
else if (type == "variable") return pass(pushcontext, pattern, expect("=>"), body, popcontext);
|
424
|
+
}
|
425
|
+
|
426
|
+
var maybeop = noComma ? maybeoperatorNoComma : maybeoperatorComma;
|
427
|
+
if (atomicTypes.hasOwnProperty(type)) return cont(maybeop);
|
428
|
+
if (type == "function") return cont(functiondef, maybeop);
|
429
|
+
if (type == "class" || (isTS && value == "interface")) { cx.marked = "keyword"; return cont(pushlex("form"), classExpression, poplex); }
|
430
|
+
if (type == "keyword c" || type == "async") return cont(noComma ? expressionNoComma : expression);
|
431
|
+
if (type == "(") return cont(pushlex(")"), maybeexpression, expect(")"), poplex, maybeop);
|
432
|
+
if (type == "operator" || type == "spread") return cont(noComma ? expressionNoComma : expression);
|
433
|
+
if (type == "[") return cont(pushlex("]"), arrayLiteral, poplex, maybeop);
|
434
|
+
if (type == "{") return contCommasep(objprop, "}", null, maybeop);
|
435
|
+
if (type == "quasi") return pass(quasi, maybeop);
|
436
|
+
if (type == "new") return cont(maybeTarget(noComma));
|
437
|
+
if (type == "import") return cont(expression);
|
438
|
+
return cont();
|
439
|
+
}
|
440
|
+
function maybeexpression(type) {
|
441
|
+
if (type.match(/[;\}\)\],]/)) return pass();
|
442
|
+
return pass(expression);
|
443
|
+
}
|
444
|
+
|
445
|
+
function maybeoperatorComma(type, value) {
|
446
|
+
if (type == ",") return cont(expression);
|
447
|
+
return maybeoperatorNoComma(type, value, false);
|
448
|
+
}
|
449
|
+
function maybeoperatorNoComma(type, value, noComma) {
|
450
|
+
var me = noComma == false ? maybeoperatorComma : maybeoperatorNoComma;
|
451
|
+
var expr = noComma == false ? expression : expressionNoComma;
|
452
|
+
if (type == "=>") return cont(pushcontext, noComma ? arrowBodyNoComma : arrowBody, popcontext);
|
453
|
+
if (type == "operator") {
|
454
|
+
if (/\+\+|--/.test(value) || isTS && value == "!") return cont(me);
|
455
|
+
if (isTS && value == "<" && cx.stream.match(/^([^>]|<.*?>)*>\s*\(/, false))
|
456
|
+
return cont(pushlex(">"), commasep(typeexpr, ">"), poplex, me);
|
457
|
+
if (value == "?") return cont(expression, expect(":"), expr);
|
458
|
+
return cont(expr);
|
459
|
+
}
|
460
|
+
if (type == "quasi") { return pass(quasi, me); }
|
461
|
+
if (type == ";") return;
|
462
|
+
if (type == "(") return contCommasep(expressionNoComma, ")", "call", me);
|
463
|
+
if (type == ".") return cont(property, me);
|
464
|
+
if (type == "[") return cont(pushlex("]"), maybeexpression, expect("]"), poplex, me);
|
465
|
+
if (isTS && value == "as") { cx.marked = "keyword"; return cont(typeexpr, me) }
|
466
|
+
if (type == "regexp") {
|
467
|
+
cx.state.lastType = cx.marked = "operator"
|
468
|
+
cx.stream.backUp(cx.stream.pos - cx.stream.start - 1)
|
469
|
+
return cont(expr)
|
470
|
+
}
|
471
|
+
}
|
472
|
+
function quasi(type, value) {
|
473
|
+
if (type != "quasi") return pass();
|
474
|
+
if (value.slice(value.length - 2) != "${") return cont(quasi);
|
475
|
+
return cont(expression, continueQuasi);
|
476
|
+
}
|
477
|
+
function continueQuasi(type) {
|
478
|
+
if (type == "}") {
|
479
|
+
cx.marked = "string-2";
|
480
|
+
cx.state.tokenize = tokenQuasi;
|
481
|
+
return cont(quasi);
|
482
|
+
}
|
483
|
+
}
|
484
|
+
function arrowBody(type) {
|
485
|
+
findFatArrow(cx.stream, cx.state);
|
486
|
+
return pass(type == "{" ? statement : expression);
|
487
|
+
}
|
488
|
+
function arrowBodyNoComma(type) {
|
489
|
+
findFatArrow(cx.stream, cx.state);
|
490
|
+
return pass(type == "{" ? statement : expressionNoComma);
|
491
|
+
}
|
492
|
+
function maybeTarget(noComma) {
|
493
|
+
return function(type) {
|
494
|
+
if (type == ".") return cont(noComma ? targetNoComma : target);
|
495
|
+
else if (type == "variable" && isTS) return cont(maybeTypeArgs, noComma ? maybeoperatorNoComma : maybeoperatorComma)
|
496
|
+
else return pass(noComma ? expressionNoComma : expression);
|
497
|
+
};
|
498
|
+
}
|
499
|
+
function target(_, value) {
|
500
|
+
if (value == "target") { cx.marked = "keyword"; return cont(maybeoperatorComma); }
|
501
|
+
}
|
502
|
+
function targetNoComma(_, value) {
|
503
|
+
if (value == "target") { cx.marked = "keyword"; return cont(maybeoperatorNoComma); }
|
504
|
+
}
|
505
|
+
function maybelabel(type) {
|
506
|
+
if (type == ":") return cont(poplex, statement);
|
507
|
+
return pass(maybeoperatorComma, expect(";"), poplex);
|
508
|
+
}
|
509
|
+
function property(type) {
|
510
|
+
if (type == "variable") {cx.marked = "property"; return cont();}
|
511
|
+
}
|
512
|
+
function objprop(type, value) {
|
513
|
+
if (type == "async") {
|
514
|
+
cx.marked = "property";
|
515
|
+
return cont(objprop);
|
516
|
+
} else if (type == "variable" || cx.style == "keyword") {
|
517
|
+
cx.marked = "property";
|
518
|
+
if (value == "get" || value == "set") return cont(getterSetter);
|
519
|
+
var m // Work around fat-arrow-detection complication for detecting typescript typed arrow params
|
520
|
+
if (isTS && cx.state.fatArrowAt == cx.stream.start && (m = cx.stream.match(/^\s*:\s*/, false)))
|
521
|
+
cx.state.fatArrowAt = cx.stream.pos + m[0].length
|
522
|
+
return cont(afterprop);
|
523
|
+
} else if (type == "number" || type == "string") {
|
524
|
+
cx.marked = jsonldMode ? "property" : (cx.style + " property");
|
525
|
+
return cont(afterprop);
|
526
|
+
} else if (type == "jsonld-keyword") {
|
527
|
+
return cont(afterprop);
|
528
|
+
} else if (isTS && isModifier(value)) {
|
529
|
+
cx.marked = "keyword"
|
530
|
+
return cont(objprop)
|
531
|
+
} else if (type == "[") {
|
532
|
+
return cont(expression, maybetype, expect("]"), afterprop);
|
533
|
+
} else if (type == "spread") {
|
534
|
+
return cont(expressionNoComma, afterprop);
|
535
|
+
} else if (value == "*") {
|
536
|
+
cx.marked = "keyword";
|
537
|
+
return cont(objprop);
|
538
|
+
} else if (type == ":") {
|
539
|
+
return pass(afterprop)
|
540
|
+
}
|
541
|
+
}
|
542
|
+
function getterSetter(type) {
|
543
|
+
if (type != "variable") return pass(afterprop);
|
544
|
+
cx.marked = "property";
|
545
|
+
return cont(functiondef);
|
546
|
+
}
|
547
|
+
function afterprop(type) {
|
548
|
+
if (type == ":") return cont(expressionNoComma);
|
549
|
+
if (type == "(") return pass(functiondef);
|
550
|
+
}
|
551
|
+
function commasep(what, end, sep) {
|
552
|
+
function proceed(type, value) {
|
553
|
+
if (sep ? sep.indexOf(type) > -1 : type == ",") {
|
554
|
+
var lex = cx.state.lexical;
|
555
|
+
if (lex.info == "call") lex.pos = (lex.pos || 0) + 1;
|
556
|
+
return cont(function(type, value) {
|
557
|
+
if (type == end || value == end) return pass()
|
558
|
+
return pass(what)
|
559
|
+
}, proceed);
|
560
|
+
}
|
561
|
+
if (type == end || value == end) return cont();
|
562
|
+
if (sep && sep.indexOf(";") > -1) return pass(what)
|
563
|
+
return cont(expect(end));
|
564
|
+
}
|
565
|
+
return function(type, value) {
|
566
|
+
if (type == end || value == end) return cont();
|
567
|
+
return pass(what, proceed);
|
568
|
+
};
|
569
|
+
}
|
570
|
+
function contCommasep(what, end, info) {
|
571
|
+
for (var i = 3; i < arguments.length; i++)
|
572
|
+
cx.cc.push(arguments[i]);
|
573
|
+
return cont(pushlex(end, info), commasep(what, end), poplex);
|
574
|
+
}
|
575
|
+
function block(type) {
|
576
|
+
if (type == "}") return cont();
|
577
|
+
return pass(statement, block);
|
578
|
+
}
|
579
|
+
function maybetype(type, value) {
|
580
|
+
if (isTS) {
|
581
|
+
if (type == ":") return cont(typeexpr);
|
582
|
+
if (value == "?") return cont(maybetype);
|
583
|
+
}
|
584
|
+
}
|
585
|
+
function maybetypeOrIn(type, value) {
|
586
|
+
if (isTS && (type == ":" || value == "in")) return cont(typeexpr)
|
587
|
+
}
|
588
|
+
function mayberettype(type) {
|
589
|
+
if (isTS && type == ":") {
|
590
|
+
if (cx.stream.match(/^\s*\w+\s+is\b/, false)) return cont(expression, isKW, typeexpr)
|
591
|
+
else return cont(typeexpr)
|
592
|
+
}
|
593
|
+
}
|
594
|
+
function isKW(_, value) {
|
595
|
+
if (value == "is") {
|
596
|
+
cx.marked = "keyword"
|
597
|
+
return cont()
|
598
|
+
}
|
599
|
+
}
|
600
|
+
function typeexpr(type, value) {
|
601
|
+
if (value == "keyof" || value == "typeof" || value == "infer") {
|
602
|
+
cx.marked = "keyword"
|
603
|
+
return cont(value == "typeof" ? expressionNoComma : typeexpr)
|
604
|
+
}
|
605
|
+
if (type == "variable" || value == "void") {
|
606
|
+
cx.marked = "type"
|
607
|
+
return cont(afterType)
|
608
|
+
}
|
609
|
+
if (value == "|" || value == "&") return cont(typeexpr)
|
610
|
+
if (type == "string" || type == "number" || type == "atom") return cont(afterType);
|
611
|
+
if (type == "[") return cont(pushlex("]"), commasep(typeexpr, "]", ","), poplex, afterType)
|
612
|
+
if (type == "{") return cont(pushlex("}"), commasep(typeprop, "}", ",;"), poplex, afterType)
|
613
|
+
if (type == "(") return cont(commasep(typearg, ")"), maybeReturnType, afterType)
|
614
|
+
if (type == "<") return cont(commasep(typeexpr, ">"), typeexpr)
|
615
|
+
}
|
616
|
+
function maybeReturnType(type) {
|
617
|
+
if (type == "=>") return cont(typeexpr)
|
618
|
+
}
|
619
|
+
function typeprop(type, value) {
|
620
|
+
if (type == "variable" || cx.style == "keyword") {
|
621
|
+
cx.marked = "property"
|
622
|
+
return cont(typeprop)
|
623
|
+
} else if (value == "?" || type == "number" || type == "string") {
|
624
|
+
return cont(typeprop)
|
625
|
+
} else if (type == ":") {
|
626
|
+
return cont(typeexpr)
|
627
|
+
} else if (type == "[") {
|
628
|
+
return cont(expect("variable"), maybetypeOrIn, expect("]"), typeprop)
|
629
|
+
} else if (type == "(") {
|
630
|
+
return pass(functiondecl, typeprop)
|
631
|
+
}
|
632
|
+
}
|
633
|
+
function typearg(type, value) {
|
634
|
+
if (type == "variable" && cx.stream.match(/^\s*[?:]/, false) || value == "?") return cont(typearg)
|
635
|
+
if (type == ":") return cont(typeexpr)
|
636
|
+
if (type == "spread") return cont(typearg)
|
637
|
+
return pass(typeexpr)
|
638
|
+
}
|
639
|
+
function afterType(type, value) {
|
640
|
+
if (value == "<") return cont(pushlex(">"), commasep(typeexpr, ">"), poplex, afterType)
|
641
|
+
if (value == "|" || type == "." || value == "&") return cont(typeexpr)
|
642
|
+
if (type == "[") return cont(typeexpr, expect("]"), afterType)
|
643
|
+
if (value == "extends" || value == "implements") { cx.marked = "keyword"; return cont(typeexpr) }
|
644
|
+
if (value == "?") return cont(typeexpr, expect(":"), typeexpr)
|
645
|
+
}
|
646
|
+
function maybeTypeArgs(_, value) {
|
647
|
+
if (value == "<") return cont(pushlex(">"), commasep(typeexpr, ">"), poplex, afterType)
|
648
|
+
}
|
649
|
+
function typeparam() {
|
650
|
+
return pass(typeexpr, maybeTypeDefault)
|
651
|
+
}
|
652
|
+
function maybeTypeDefault(_, value) {
|
653
|
+
if (value == "=") return cont(typeexpr)
|
654
|
+
}
|
655
|
+
function vardef(_, value) {
|
656
|
+
if (value == "enum") {cx.marked = "keyword"; return cont(enumdef)}
|
657
|
+
return pass(pattern, maybetype, maybeAssign, vardefCont);
|
658
|
+
}
|
659
|
+
function pattern(type, value) {
|
660
|
+
if (isTS && isModifier(value)) { cx.marked = "keyword"; return cont(pattern) }
|
661
|
+
if (type == "variable") { register(value); return cont(); }
|
662
|
+
if (type == "spread") return cont(pattern);
|
663
|
+
if (type == "[") return contCommasep(eltpattern, "]");
|
664
|
+
if (type == "{") return contCommasep(proppattern, "}");
|
665
|
+
}
|
666
|
+
function proppattern(type, value) {
|
667
|
+
if (type == "variable" && !cx.stream.match(/^\s*:/, false)) {
|
668
|
+
register(value);
|
669
|
+
return cont(maybeAssign);
|
670
|
+
}
|
671
|
+
if (type == "variable") cx.marked = "property";
|
672
|
+
if (type == "spread") return cont(pattern);
|
673
|
+
if (type == "}") return pass();
|
674
|
+
if (type == "[") return cont(expression, expect(']'), expect(':'), proppattern);
|
675
|
+
return cont(expect(":"), pattern, maybeAssign);
|
676
|
+
}
|
677
|
+
function eltpattern() {
|
678
|
+
return pass(pattern, maybeAssign)
|
679
|
+
}
|
680
|
+
function maybeAssign(_type, value) {
|
681
|
+
if (value == "=") return cont(expressionNoComma);
|
682
|
+
}
|
683
|
+
function vardefCont(type) {
|
684
|
+
if (type == ",") return cont(vardef);
|
685
|
+
}
|
686
|
+
function maybeelse(type, value) {
|
687
|
+
if (type == "keyword b" && value == "else") return cont(pushlex("form", "else"), statement, poplex);
|
688
|
+
}
|
689
|
+
function forspec(type, value) {
|
690
|
+
if (value == "await") return cont(forspec);
|
691
|
+
if (type == "(") return cont(pushlex(")"), forspec1, poplex);
|
692
|
+
}
|
693
|
+
function forspec1(type) {
|
694
|
+
if (type == "var") return cont(vardef, forspec2);
|
695
|
+
if (type == "variable") return cont(forspec2);
|
696
|
+
return pass(forspec2)
|
697
|
+
}
|
698
|
+
function forspec2(type, value) {
|
699
|
+
if (type == ")") return cont()
|
700
|
+
if (type == ";") return cont(forspec2)
|
701
|
+
if (value == "in" || value == "of") { cx.marked = "keyword"; return cont(expression, forspec2) }
|
702
|
+
return pass(expression, forspec2)
|
703
|
+
}
|
704
|
+
function functiondef(type, value) {
|
705
|
+
if (value == "*") {cx.marked = "keyword"; return cont(functiondef);}
|
706
|
+
if (type == "variable") {register(value); return cont(functiondef);}
|
707
|
+
if (type == "(") return cont(pushcontext, pushlex(")"), commasep(funarg, ")"), poplex, mayberettype, statement, popcontext);
|
708
|
+
if (isTS && value == "<") return cont(pushlex(">"), commasep(typeparam, ">"), poplex, functiondef)
|
709
|
+
}
|
710
|
+
function functiondecl(type, value) {
|
711
|
+
if (value == "*") {cx.marked = "keyword"; return cont(functiondecl);}
|
712
|
+
if (type == "variable") {register(value); return cont(functiondecl);}
|
713
|
+
if (type == "(") return cont(pushcontext, pushlex(")"), commasep(funarg, ")"), poplex, mayberettype, popcontext);
|
714
|
+
if (isTS && value == "<") return cont(pushlex(">"), commasep(typeparam, ">"), poplex, functiondecl)
|
715
|
+
}
|
716
|
+
function typename(type, value) {
|
717
|
+
if (type == "keyword" || type == "variable") {
|
718
|
+
cx.marked = "type"
|
719
|
+
return cont(typename)
|
720
|
+
} else if (value == "<") {
|
721
|
+
return cont(pushlex(">"), commasep(typeparam, ">"), poplex)
|
722
|
+
}
|
723
|
+
}
|
724
|
+
function funarg(type, value) {
|
725
|
+
if (value == "@") cont(expression, funarg)
|
726
|
+
if (type == "spread") return cont(funarg);
|
727
|
+
if (isTS && isModifier(value)) { cx.marked = "keyword"; return cont(funarg); }
|
728
|
+
if (isTS && type == "this") return cont(maybetype, maybeAssign)
|
729
|
+
return pass(pattern, maybetype, maybeAssign);
|
730
|
+
}
|
731
|
+
function classExpression(type, value) {
|
732
|
+
// Class expressions may have an optional name.
|
733
|
+
if (type == "variable") return className(type, value);
|
734
|
+
return classNameAfter(type, value);
|
735
|
+
}
|
736
|
+
function className(type, value) {
|
737
|
+
if (type == "variable") {register(value); return cont(classNameAfter);}
|
738
|
+
}
|
739
|
+
function classNameAfter(type, value) {
|
740
|
+
if (value == "<") return cont(pushlex(">"), commasep(typeparam, ">"), poplex, classNameAfter)
|
741
|
+
if (value == "extends" || value == "implements" || (isTS && type == ",")) {
|
742
|
+
if (value == "implements") cx.marked = "keyword";
|
743
|
+
return cont(isTS ? typeexpr : expression, classNameAfter);
|
744
|
+
}
|
745
|
+
if (type == "{") return cont(pushlex("}"), classBody, poplex);
|
746
|
+
}
|
747
|
+
function classBody(type, value) {
|
748
|
+
if (type == "async" ||
|
749
|
+
(type == "variable" &&
|
750
|
+
(value == "static" || value == "get" || value == "set" || (isTS && isModifier(value))) &&
|
751
|
+
cx.stream.match(/^\s+[\w$\xa1-\uffff]/, false))) {
|
752
|
+
cx.marked = "keyword";
|
753
|
+
return cont(classBody);
|
754
|
+
}
|
755
|
+
if (type == "variable" || cx.style == "keyword") {
|
756
|
+
cx.marked = "property";
|
757
|
+
return cont(isTS ? classfield : functiondef, classBody);
|
758
|
+
}
|
759
|
+
if (type == "number" || type == "string") return cont(isTS ? classfield : functiondef, classBody);
|
760
|
+
if (type == "[")
|
761
|
+
return cont(expression, maybetype, expect("]"), isTS ? classfield : functiondef, classBody)
|
762
|
+
if (value == "*") {
|
763
|
+
cx.marked = "keyword";
|
764
|
+
return cont(classBody);
|
765
|
+
}
|
766
|
+
if (isTS && type == "(") return pass(functiondecl, classBody)
|
767
|
+
if (type == ";" || type == ",") return cont(classBody);
|
768
|
+
if (type == "}") return cont();
|
769
|
+
if (value == "@") return cont(expression, classBody)
|
770
|
+
}
|
771
|
+
function classfield(type, value) {
|
772
|
+
if (value == "?") return cont(classfield)
|
773
|
+
if (type == ":") return cont(typeexpr, maybeAssign)
|
774
|
+
if (value == "=") return cont(expressionNoComma)
|
775
|
+
var context = cx.state.lexical.prev, isInterface = context && context.info == "interface"
|
776
|
+
return pass(isInterface ? functiondecl : functiondef)
|
777
|
+
}
|
778
|
+
function afterExport(type, value) {
|
779
|
+
if (value == "*") { cx.marked = "keyword"; return cont(maybeFrom, expect(";")); }
|
780
|
+
if (value == "default") { cx.marked = "keyword"; return cont(expression, expect(";")); }
|
781
|
+
if (type == "{") return cont(commasep(exportField, "}"), maybeFrom, expect(";"));
|
782
|
+
return pass(statement);
|
783
|
+
}
|
784
|
+
function exportField(type, value) {
|
785
|
+
if (value == "as") { cx.marked = "keyword"; return cont(expect("variable")); }
|
786
|
+
if (type == "variable") return pass(expressionNoComma, exportField);
|
787
|
+
}
|
788
|
+
function afterImport(type) {
|
789
|
+
if (type == "string") return cont();
|
790
|
+
if (type == "(") return pass(expression);
|
791
|
+
return pass(importSpec, maybeMoreImports, maybeFrom);
|
792
|
+
}
|
793
|
+
function importSpec(type, value) {
|
794
|
+
if (type == "{") return contCommasep(importSpec, "}");
|
795
|
+
if (type == "variable") register(value);
|
796
|
+
if (value == "*") cx.marked = "keyword";
|
797
|
+
return cont(maybeAs);
|
798
|
+
}
|
799
|
+
function maybeMoreImports(type) {
|
800
|
+
if (type == ",") return cont(importSpec, maybeMoreImports)
|
801
|
+
}
|
802
|
+
function maybeAs(_type, value) {
|
803
|
+
if (value == "as") { cx.marked = "keyword"; return cont(importSpec); }
|
804
|
+
}
|
805
|
+
function maybeFrom(_type, value) {
|
806
|
+
if (value == "from") { cx.marked = "keyword"; return cont(expression); }
|
807
|
+
}
|
808
|
+
function arrayLiteral(type) {
|
809
|
+
if (type == "]") return cont();
|
810
|
+
return pass(commasep(expressionNoComma, "]"));
|
811
|
+
}
|
812
|
+
function enumdef() {
|
813
|
+
return pass(pushlex("form"), pattern, expect("{"), pushlex("}"), commasep(enummember, "}"), poplex, poplex)
|
814
|
+
}
|
815
|
+
function enummember() {
|
816
|
+
return pass(pattern, maybeAssign);
|
817
|
+
}
|
818
|
+
|
819
|
+
function isContinuedStatement(state, textAfter) {
|
820
|
+
return state.lastType == "operator" || state.lastType == "," ||
|
821
|
+
isOperatorChar.test(textAfter.charAt(0)) ||
|
822
|
+
/[,.]/.test(textAfter.charAt(0));
|
823
|
+
}
|
824
|
+
|
825
|
+
function expressionAllowed(stream, state, backUp) {
|
826
|
+
return state.tokenize == tokenBase &&
|
827
|
+
/^(?:operator|sof|keyword [bcd]|case|new|export|default|spread|[\[{}\(,;:]|=>)$/.test(state.lastType) ||
|
828
|
+
(state.lastType == "quasi" && /\{\s*$/.test(stream.string.slice(0, stream.pos - (backUp || 0))))
|
829
|
+
}
|
830
|
+
|
831
|
+
// Interface
|
832
|
+
|
833
|
+
return {
|
834
|
+
startState: function(basecolumn) {
|
835
|
+
var state = {
|
836
|
+
tokenize: tokenBase,
|
837
|
+
lastType: "sof",
|
838
|
+
cc: [],
|
839
|
+
lexical: new JSLexical((basecolumn || 0) - indentUnit, 0, "block", false),
|
840
|
+
localVars: parserConfig.localVars,
|
841
|
+
context: parserConfig.localVars && new Context(null, null, false),
|
842
|
+
indented: basecolumn || 0
|
843
|
+
};
|
844
|
+
if (parserConfig.globalVars && typeof parserConfig.globalVars == "object")
|
845
|
+
state.globalVars = parserConfig.globalVars;
|
846
|
+
return state;
|
847
|
+
},
|
848
|
+
|
849
|
+
token: function(stream, state) {
|
850
|
+
if (stream.sol()) {
|
851
|
+
if (!state.lexical.hasOwnProperty("align"))
|
852
|
+
state.lexical.align = false;
|
853
|
+
state.indented = stream.indentation();
|
854
|
+
findFatArrow(stream, state);
|
855
|
+
}
|
856
|
+
if (state.tokenize != tokenComment && stream.eatSpace()) return null;
|
857
|
+
var style = state.tokenize(stream, state);
|
858
|
+
if (type == "comment") return style;
|
859
|
+
state.lastType = type == "operator" && (content == "++" || content == "--") ? "incdec" : type;
|
860
|
+
return parseJS(state, style, type, content, stream);
|
861
|
+
},
|
862
|
+
|
863
|
+
indent: function(state, textAfter) {
|
864
|
+
if (state.tokenize == tokenComment) return CodeMirror.Pass;
|
865
|
+
if (state.tokenize != tokenBase) return 0;
|
866
|
+
var firstChar = textAfter && textAfter.charAt(0), lexical = state.lexical, top
|
867
|
+
// Kludge to prevent 'maybelse' from blocking lexical scope pops
|
868
|
+
if (!/^\s*else\b/.test(textAfter)) for (var i = state.cc.length - 1; i >= 0; --i) {
|
869
|
+
var c = state.cc[i];
|
870
|
+
if (c == poplex) lexical = lexical.prev;
|
871
|
+
else if (c != maybeelse) break;
|
872
|
+
}
|
873
|
+
while ((lexical.type == "stat" || lexical.type == "form") &&
|
874
|
+
(firstChar == "}" || ((top = state.cc[state.cc.length - 1]) &&
|
875
|
+
(top == maybeoperatorComma || top == maybeoperatorNoComma) &&
|
876
|
+
!/^[,\.=+\-*:?[\(]/.test(textAfter))))
|
877
|
+
lexical = lexical.prev;
|
878
|
+
if (statementIndent && lexical.type == ")" && lexical.prev.type == "stat")
|
879
|
+
lexical = lexical.prev;
|
880
|
+
var type = lexical.type, closing = firstChar == type;
|
881
|
+
|
882
|
+
if (type == "vardef") return lexical.indented + (state.lastType == "operator" || state.lastType == "," ? lexical.info.length + 1 : 0);
|
883
|
+
else if (type == "form" && firstChar == "{") return lexical.indented;
|
884
|
+
else if (type == "form") return lexical.indented + indentUnit;
|
885
|
+
else if (type == "stat")
|
886
|
+
return lexical.indented + (isContinuedStatement(state, textAfter) ? statementIndent || indentUnit : 0);
|
887
|
+
else if (lexical.info == "switch" && !closing && parserConfig.doubleIndentSwitch != false)
|
888
|
+
return lexical.indented + (/^(?:case|default)\b/.test(textAfter) ? indentUnit : 2 * indentUnit);
|
889
|
+
else if (lexical.align) return lexical.column + (closing ? 0 : 1);
|
890
|
+
else return lexical.indented + (closing ? 0 : indentUnit);
|
891
|
+
},
|
892
|
+
|
893
|
+
electricInput: /^\s*(?:case .*?:|default:|\{|\})$/,
|
894
|
+
blockCommentStart: jsonMode ? null : "/*",
|
895
|
+
blockCommentEnd: jsonMode ? null : "*/",
|
896
|
+
blockCommentContinue: jsonMode ? null : " * ",
|
897
|
+
lineComment: jsonMode ? null : "//",
|
898
|
+
fold: "brace",
|
899
|
+
closeBrackets: "()[]{}''\"\"``",
|
900
|
+
|
901
|
+
helperType: jsonMode ? "json" : "javascript",
|
902
|
+
jsonldMode: jsonldMode,
|
903
|
+
jsonMode: jsonMode,
|
904
|
+
|
905
|
+
expressionAllowed: expressionAllowed,
|
906
|
+
|
907
|
+
skipExpression: function(state) {
|
908
|
+
var top = state.cc[state.cc.length - 1]
|
909
|
+
if (top == expression || top == expressionNoComma) state.cc.pop()
|
910
|
+
}
|
911
|
+
};
|
912
|
+
});
|
913
|
+
|
914
|
+
CodeMirror.registerHelper("wordChars", "javascript", /[\w$]/);
|
915
|
+
|
916
|
+
CodeMirror.defineMIME("text/javascript", "javascript");
|
917
|
+
CodeMirror.defineMIME("text/ecmascript", "javascript");
|
918
|
+
CodeMirror.defineMIME("application/javascript", "javascript");
|
919
|
+
CodeMirror.defineMIME("application/x-javascript", "javascript");
|
920
|
+
CodeMirror.defineMIME("application/ecmascript", "javascript");
|
921
|
+
CodeMirror.defineMIME("application/json", {name: "javascript", json: true});
|
922
|
+
CodeMirror.defineMIME("application/x-json", {name: "javascript", json: true});
|
923
|
+
CodeMirror.defineMIME("application/ld+json", {name: "javascript", jsonld: true});
|
924
|
+
CodeMirror.defineMIME("text/typescript", { name: "javascript", typescript: true });
|
925
|
+
CodeMirror.defineMIME("application/typescript", { name: "javascript", typescript: true });
|
926
|
+
|
927
|
+
});
|