mdbe 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/LICENSE.txt +21 -0
- data/README.md +53 -0
- data/app.rb +182 -0
- data/bin/mdbe +5 -0
- data/config.ru +2 -0
- data/environment.rb +8 -0
- data/lib/mdbe.rb +39 -0
- data/lib/mdbe/action_controller_debug_patch.rb +12 -0
- data/lib/mdbe/code_evaluation.rb +46 -0
- data/lib/mdbe/database_views.rb +24 -0
- data/lib/mdbe/database_views/abstract_dictionary.rb +69 -0
- data/lib/mdbe/database_views/abstract_exception.rb +25 -0
- data/lib/mdbe/database_views/array.rb +28 -0
- data/lib/mdbe/database_views/boolean.rb +12 -0
- data/lib/mdbe/database_views/class.rb +46 -0
- data/lib/mdbe/database_views/exception.rb +3 -0
- data/lib/mdbe/database_views/execblock.rb +5 -0
- data/lib/mdbe/database_views/fixnum.rb +5 -0
- data/lib/mdbe/database_views/float.rb +5 -0
- data/lib/mdbe/database_views/globals.rb +2 -0
- data/lib/mdbe/database_views/gsnmethod.rb +29 -0
- data/lib/mdbe/database_views/hash.rb +5 -0
- data/lib/mdbe/database_views/maglev_record.rb +42 -0
- data/lib/mdbe/database_views/module.rb +103 -0
- data/lib/mdbe/database_views/nilclass.rb +5 -0
- data/lib/mdbe/database_views/object.rb +80 -0
- data/lib/mdbe/database_views/proc.rb +3 -0
- data/lib/mdbe/database_views/repository.rb +3 -0
- data/lib/mdbe/database_views/ruby_workspace.rb +5 -0
- data/lib/mdbe/database_views/smalltalk_classes.rb +34 -0
- data/lib/mdbe/database_views/smalltalk_classes.st +60 -0
- data/lib/mdbe/database_views/string.rb +31 -0
- data/lib/mdbe/database_views/symbol.rb +32 -0
- data/lib/mdbe/database_views/system.rb +61 -0
- data/lib/mdbe/database_views/thread.rb +101 -0
- data/lib/mdbe/debug_server.rb +22 -0
- data/lib/mdbe/halt.rb +42 -0
- data/lib/mdbe/ruby_workspace.rb +29 -0
- data/lib/mdbe/version.rb +3 -0
- data/lib/tasks/maglev-database-explorer_tasks.rake +4 -0
- data/public/LICENSE +35 -0
- data/public/amber/CHANGELOG +65 -0
- data/public/amber/LICENSE +22 -0
- data/public/amber/Makefile +53 -0
- data/public/amber/README.md +30 -0
- data/public/amber/bin/amber +3 -0
- data/public/amber/bin/amberc +352 -0
- data/public/amber/bin/nodecompile.js +33 -0
- data/public/amber/bin/server +3 -0
- data/public/amber/bin/server.bat +3 -0
- data/public/amber/css/amber-normalize.css +468 -0
- data/public/amber/css/amber-normalize.less +501 -0
- data/public/amber/css/amber.css +539 -0
- data/public/amber/css/documentation.css +84 -0
- data/public/amber/css/profstef.css +75 -0
- data/public/amber/css/style.css +313 -0
- data/public/amber/documentation.html +37 -0
- data/public/amber/examples/Makefile +23 -0
- data/public/amber/examples/README +4 -0
- data/public/amber/examples/android/helloamber/AndroidManifest.xml +19 -0
- data/public/amber/examples/android/helloamber/HelloAmber.st +13 -0
- data/public/amber/examples/android/helloamber/Makefile +56 -0
- data/public/amber/examples/android/helloamber/README.md +80 -0
- data/public/amber/examples/android/helloamber/ant.properties +17 -0
- data/public/amber/examples/android/helloamber/assets/index.html +15 -0
- data/public/amber/examples/android/helloamber/assets/jquery-1.7.2.min.js +4 -0
- data/public/amber/examples/android/helloamber/build.xml +83 -0
- data/public/amber/examples/android/helloamber/local.properties +10 -0
- data/public/amber/examples/android/helloamber/proguard-project.txt +20 -0
- data/public/amber/examples/android/helloamber/project.properties +14 -0
- data/public/amber/examples/android/helloamber/res/layout/main.xml +6 -0
- data/public/amber/examples/android/helloamber/res/values/strings.xml +4 -0
- data/public/amber/examples/android/helloamber/src/org/amberlang/android/helloamber/HelloAmber.java +59 -0
- data/public/amber/examples/myproject/index.html +16 -0
- data/public/amber/examples/nodejs/README +9 -0
- data/public/amber/examples/nodejs/benchfib/Benchfib.st +124 -0
- data/public/amber/examples/nodejs/benchfib/Makefile +8 -0
- data/public/amber/examples/nodejs/benchfib/benchfib +1 -0
- data/public/amber/examples/nodejs/hello/Hello.st +9 -0
- data/public/amber/examples/nodejs/hello/Makefile +8 -0
- data/public/amber/examples/nodejs/hello/README +13 -0
- data/public/amber/examples/nodejs/hello/hello +1 -0
- data/public/amber/examples/nodejs/meta/Makefile +8 -0
- data/public/amber/examples/nodejs/meta/MyScript.st +27 -0
- data/public/amber/examples/nodejs/meta/meta +1 -0
- data/public/amber/examples/nodejs/pystone/Makefile +8 -0
- data/public/amber/examples/nodejs/pystone/Pystone.st +306 -0
- data/public/amber/examples/nodejs/pystone/pystone +1 -0
- data/public/amber/examples/nodejs/trivialserver/Makefile +8 -0
- data/public/amber/examples/nodejs/trivialserver/TrivialServer.st +51 -0
- data/public/amber/examples/nodejs/trivialserver/trivial +1 -0
- data/public/amber/examples/presentation/esug2011/images/asterix.png +0 -0
- data/public/amber/examples/presentation/esug2011/images/background_box.png +0 -0
- data/public/amber/examples/presentation/esug2011/images/background_header.png +0 -0
- data/public/amber/examples/presentation/esug2011/images/balloon.jpg +0 -0
- data/public/amber/examples/presentation/esug2011/images/balloon_header.png +0 -0
- data/public/amber/examples/presentation/esug2011/images/devices.jpg +0 -0
- data/public/amber/examples/presentation/esug2011/images/enyo.png +0 -0
- data/public/amber/examples/presentation/esug2011/images/ide_star_wars.png +0 -0
- data/public/amber/examples/presentation/esug2011/images/nodejs.png +0 -0
- data/public/amber/examples/presentation/esug2011/images/terminal.png +0 -0
- data/public/amber/examples/presentation/esug2011/images/webos.png +0 -0
- data/public/amber/examples/presentation/fosdem2012/images/amber.png +0 -0
- data/public/amber/examples/presentation/fosdem2012/images/ambrhino.jpg +0 -0
- data/public/amber/examples/presentation/fosdem2012/images/nodejs.png +0 -0
- data/public/amber/examples/presentation/fosdem2012/images/pharo.png +0 -0
- data/public/amber/examples/presentation/fosdem2012/images/php.gif +0 -0
- data/public/amber/examples/presentation/fosdem2012/images/rails.png +0 -0
- data/public/amber/examples/presentation/fosdem2012/lib/booklet/images/arrow-next.png +0 -0
- data/public/amber/examples/presentation/fosdem2012/lib/booklet/images/arrow-prev.png +0 -0
- data/public/amber/examples/presentation/fosdem2012/lib/booklet/images/closedhand.cur +0 -0
- data/public/amber/examples/presentation/fosdem2012/lib/booklet/images/openhand.cur +0 -0
- data/public/amber/examples/presentation/fosdem2012/lib/booklet/images/shadow-top-back.png +0 -0
- data/public/amber/examples/presentation/fosdem2012/lib/booklet/images/shadow-top-forward.png +0 -0
- data/public/amber/examples/presentation/fosdem2012/lib/booklet/images/shadow.png +0 -0
- data/public/amber/examples/presentation/fosdem2012/lib/booklet/jquery.booklet.1.2.0.css +100 -0
- data/public/amber/examples/presentation/fosdem2012/lib/booklet/jquery.booklet.1.2.0.js +1232 -0
- data/public/amber/examples/presentation/fosdem2012/lib/booklet/jquery.booklet.1.2.0.min.js +13 -0
- data/public/amber/examples/presentation/fosdem2012/lib/booklet/jquery.easing.1.3.js +38 -0
- data/public/amber/examples/presentation/index.html +17 -0
- data/public/amber/examples/presentation/js/Presentation.deploy.js +1922 -0
- data/public/amber/examples/presentation/js/Presentation.js +2712 -0
- data/public/amber/examples/presentation/st/Presentation.st +1996 -0
- data/public/amber/examples/trysmalltalk/index.html +18 -0
- data/public/amber/examples/trysmalltalk/js/TrySmalltalk.deploy.js +837 -0
- data/public/amber/examples/trysmalltalk/js/TrySmalltalk.js +1206 -0
- data/public/amber/examples/trysmalltalk/st/TrySmalltalk.st +964 -0
- data/public/amber/examples/twitterwall/css/twitterwall.css +19 -0
- data/public/amber/examples/twitterwall/index.html +35 -0
- data/public/amber/examples/twitterwall/js/TwitterWall.deploy.js +116 -0
- data/public/amber/examples/twitterwall/js/TwitterWall.js +146 -0
- data/public/amber/examples/twitterwall/st/TwitterWall.st +91 -0
- data/public/amber/examples/webos/README +11 -0
- data/public/amber/examples/webos/eris/DuckQwaq.wav +0 -0
- data/public/amber/examples/webos/eris/EnyoAmber.st +36 -0
- data/public/amber/examples/webos/eris/Eris.css +0 -0
- data/public/amber/examples/webos/eris/Eris.st +86 -0
- data/public/amber/examples/webos/eris/Makefile +37 -0
- data/public/amber/examples/webos/eris/README +3 -0
- data/public/amber/examples/webos/eris/appinfo.json +10 -0
- data/public/amber/examples/webos/eris/index.html +12 -0
- data/public/amber/examples/webos/helloamber/EnyoAmber.st +36 -0
- data/public/amber/examples/webos/helloamber/HelloAmber.st +86 -0
- data/public/amber/examples/webos/helloamber/Makefile +38 -0
- data/public/amber/examples/webos/helloamber/README +5 -0
- data/public/amber/examples/webos/helloamber/appinfo.json +10 -0
- data/public/amber/examples/webos/helloamber/index.html +12 -0
- data/public/amber/favicon.ico +0 -0
- data/public/amber/images/amber.png +0 -0
- data/public/amber/images/amber.svg +706 -0
- data/public/amber/images/amber_small.png +0 -0
- data/public/amber/images/off.amber.png +0 -0
- data/public/amber/images/off.png +0 -0
- data/public/amber/images/offHover.amber.png +0 -0
- data/public/amber/images/offHover.png +0 -0
- data/public/amber/images/presentation.png +0 -0
- data/public/amber/images/profstef.png +0 -0
- data/public/amber/images/sprite.amber.png +0 -0
- data/public/amber/images/sprite.png +0 -0
- data/public/amber/images/tinylogo.amber.png +0 -0
- data/public/amber/images/tinylogo.png +0 -0
- data/public/amber/images/twitterwall.png +0 -0
- data/public/amber/index.html +55 -0
- data/public/amber/js/Additional-Examples.deploy.js +15 -0
- data/public/amber/js/Additional-Examples.js +21 -0
- data/public/amber/js/Benchfib.deploy.js +132 -0
- data/public/amber/js/Benchfib.js +167 -0
- data/public/amber/js/Canvas.deploy.js +2446 -0
- data/public/amber/js/Canvas.js +3547 -0
- data/public/amber/js/Compiler-Tests.deploy.js +97 -0
- data/public/amber/js/Compiler-Tests.js +137 -0
- data/public/amber/js/Compiler.deploy.js +1877 -0
- data/public/amber/js/Compiler.js +2622 -0
- data/public/amber/js/Documentation.deploy.js +961 -0
- data/public/amber/js/Documentation.js +1376 -0
- data/public/amber/js/Examples.deploy.js +53 -0
- data/public/amber/js/Examples.js +73 -0
- data/public/amber/js/IDE.deploy.js +3557 -0
- data/public/amber/js/IDE.js +5002 -0
- data/public/amber/js/Kernel-Announcements.deploy.js +107 -0
- data/public/amber/js/Kernel-Announcements.js +152 -0
- data/public/amber/js/Kernel-Classes.deploy.js +774 -0
- data/public/amber/js/Kernel-Classes.js +1095 -0
- data/public/amber/js/Kernel-Collections.deploy.js +3121 -0
- data/public/amber/js/Kernel-Collections.js +4427 -0
- data/public/amber/js/Kernel-Exceptions.deploy.js +244 -0
- data/public/amber/js/Kernel-Exceptions.js +349 -0
- data/public/amber/js/Kernel-Methods.deploy.js +573 -0
- data/public/amber/js/Kernel-Methods.js +807 -0
- data/public/amber/js/Kernel-Objects.deploy.js +2877 -0
- data/public/amber/js/Kernel-Objects.js +4107 -0
- data/public/amber/js/Kernel-Tests.deploy.js +1513 -0
- data/public/amber/js/Kernel-Tests.js +2053 -0
- data/public/amber/js/Kernel-Transcript.deploy.js +142 -0
- data/public/amber/js/Kernel-Transcript.js +202 -0
- data/public/amber/js/Maglev-Core.deploy.js +2996 -0
- data/public/amber/js/Maglev-Core.js +4246 -0
- data/public/amber/js/Maglev-Database-Explorer.deploy.js +4476 -0
- data/public/amber/js/Maglev-Database-Explorer.js +6232 -0
- data/public/amber/js/Maglev-Vendor.deploy.js +350 -0
- data/public/amber/js/Maglev-Vendor.js +465 -0
- data/public/amber/js/README.md +5 -0
- data/public/amber/js/SUnit.deploy.js +351 -0
- data/public/amber/js/SUnit.js +501 -0
- data/public/amber/js/amber.js +273 -0
- data/public/amber/js/boot.js +602 -0
- data/public/amber/js/compat.js +22 -0
- data/public/amber/js/init.js +9 -0
- data/public/amber/js/lib/CodeMirror/LICENSE +19 -0
- data/public/amber/js/lib/CodeMirror/active-line.js +39 -0
- data/public/amber/js/lib/CodeMirror/amber.css +21 -0
- data/public/amber/js/lib/CodeMirror/codemirror.css +67 -0
- data/public/amber/js/lib/CodeMirror/codemirror.js +2144 -0
- data/public/amber/js/lib/CodeMirror/smalltalk.js +134 -0
- data/public/amber/js/lib/jQuery/jquery-1.4.4.min.js +167 -0
- data/public/amber/js/lib/jQuery/jquery-1.6.4.min.js +4 -0
- data/public/amber/js/lib/jQuery/jquery-ui-1.8.16.custom.min.js +791 -0
- data/public/amber/js/lib/jQuery/jquery.textarea.js +267 -0
- data/public/amber/js/lib/peg-0.6.2.min.js +2 -0
- data/public/amber/js/lib/showdown.js +419 -0
- data/public/amber/js/parser.js +4222 -0
- data/public/amber/js/parser.pegjs +223 -0
- data/public/amber/learn.html +40 -0
- data/public/amber/repl/Makefile +8 -0
- data/public/amber/repl/REPL.js +124 -0
- data/public/amber/repl/REPL.st +56 -0
- data/public/amber/repl/amber.js +18085 -0
- data/public/amber/server/FileServer.st +576 -0
- data/public/amber/server/Makefile +8 -0
- data/public/amber/server/server.js +13049 -0
- data/public/amber/st/Benchfib.js +297 -0
- data/public/amber/st/Benchfib.st +124 -0
- data/public/amber/st/Canvas.st +968 -0
- data/public/amber/st/Compiler-Tests.st +471 -0
- data/public/amber/st/Compiler.st +1445 -0
- data/public/amber/st/Documentation.st +758 -0
- data/public/amber/st/Examples.js +100 -0
- data/public/amber/st/Examples.st +38 -0
- data/public/amber/st/IDE.st +2404 -0
- data/public/amber/st/Kernel-Announcements.st +61 -0
- data/public/amber/st/Kernel-Classes.st +462 -0
- data/public/amber/st/Kernel-Collections.st +1611 -0
- data/public/amber/st/Kernel-Exceptions.st +124 -0
- data/public/amber/st/Kernel-Methods.st +291 -0
- data/public/amber/st/Kernel-Objects.st +1587 -0
- data/public/amber/st/Kernel-Tests.st +953 -0
- data/public/amber/st/Kernel-Transcript.st +70 -0
- data/public/amber/st/Maglev-Core.st +1694 -0
- data/public/amber/st/Maglev-Database-Explorer.st +3148 -0
- data/public/amber/st/Maglev-Vendor.st +151 -0
- data/public/amber/st/Makefile +104 -0
- data/public/amber/st/README.md +4 -0
- data/public/amber/st/SUnit.st +172 -0
- data/public/css/bootstrap-combined.no-icons.min.css +731 -0
- data/public/css/bootstrap.css +6811 -0
- data/public/css/images/animated-overlay.gif +0 -0
- data/public/css/images/ui-bg_diagonals-thick_18_b81900_40x40.png +0 -0
- data/public/css/images/ui-bg_diagonals-thick_20_666666_40x40.png +0 -0
- data/public/css/images/ui-bg_flat_10_000000_40x100.png +0 -0
- data/public/css/images/ui-bg_glass_100_f6f6f6_1x400.png +0 -0
- data/public/css/images/ui-bg_glass_100_fdf5ce_1x400.png +0 -0
- data/public/css/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/public/css/images/ui-bg_gloss-wave_35_f6a828_500x100.png +0 -0
- data/public/css/images/ui-bg_highlight-soft_100_eeeeee_1x100.png +0 -0
- data/public/css/images/ui-bg_highlight-soft_75_ffe45c_1x100.png +0 -0
- data/public/css/images/ui-icons_222222_256x240.png +0 -0
- data/public/css/images/ui-icons_228ef1_256x240.png +0 -0
- data/public/css/images/ui-icons_ef8c08_256x240.png +0 -0
- data/public/css/images/ui-icons_ffd27a_256x240.png +0 -0
- data/public/css/images/ui-icons_ffffff_256x240.png +0 -0
- data/public/css/jquery-ui.min.css +5 -0
- data/public/css/smalltalk_code.css +42 -0
- data/public/css/style.css +210 -0
- data/public/images/bg_tile.png +0 -0
- data/public/images/maglev-logo.gif +0 -0
- data/public/images/mchammer.gif +0 -0
- data/public/images/rails_tiny.png +0 -0
- data/public/images/ruby.png +0 -0
- data/public/images/ruby_smalltalk_bridge.png +0 -0
- data/public/images/smalltalk.png +0 -0
- data/public/img/glyphicons-halflings.png +0 -0
- data/public/index.html +118 -0
- data/public/libs/bootstrap.min.js +7 -0
- data/public/libs/codemirror/CONTRIBUTING.md +72 -0
- data/public/libs/codemirror/LICENSE +23 -0
- data/public/libs/codemirror/README.md +11 -0
- data/public/libs/codemirror/addon/dialog/dialog.css +32 -0
- data/public/libs/codemirror/addon/dialog/dialog.js +80 -0
- data/public/libs/codemirror/addon/display/placeholder.js +54 -0
- data/public/libs/codemirror/addon/edit/closebrackets.js +54 -0
- data/public/libs/codemirror/addon/edit/closetag.js +86 -0
- data/public/libs/codemirror/addon/edit/continuecomment.js +44 -0
- data/public/libs/codemirror/addon/edit/continuelist.js +25 -0
- data/public/libs/codemirror/addon/edit/matchbrackets.js +82 -0
- data/public/libs/codemirror/addon/fold/brace-fold.js +31 -0
- data/public/libs/codemirror/addon/fold/foldcode.js +32 -0
- data/public/libs/codemirror/addon/fold/indent-fold.js +11 -0
- data/public/libs/codemirror/addon/fold/xml-fold.js +64 -0
- data/public/libs/codemirror/addon/hint/html-hint.js +582 -0
- data/public/libs/codemirror/addon/hint/javascript-hint.js +142 -0
- data/public/libs/codemirror/addon/hint/pig-hint.js +117 -0
- data/public/libs/codemirror/addon/hint/python-hint.js +93 -0
- data/public/libs/codemirror/addon/hint/show-hint.css +38 -0
- data/public/libs/codemirror/addon/hint/show-hint.js +180 -0
- data/public/libs/codemirror/addon/hint/xml-hint.js +118 -0
- data/public/libs/codemirror/addon/lint/javascript-lint.js +127 -0
- data/public/libs/codemirror/addon/lint/json-lint.js +14 -0
- data/public/libs/codemirror/addon/lint/lint.css +96 -0
- data/public/libs/codemirror/addon/lint/lint.js +197 -0
- data/public/libs/codemirror/addon/mode/loadmode.js +51 -0
- data/public/libs/codemirror/addon/mode/multiplex.js +95 -0
- data/public/libs/codemirror/addon/mode/overlay.js +59 -0
- data/public/libs/codemirror/addon/runmode/colorize.js +29 -0
- data/public/libs/codemirror/addon/runmode/runmode-standalone.js +130 -0
- data/public/libs/codemirror/addon/runmode/runmode.js +52 -0
- data/public/libs/codemirror/addon/runmode/runmode.node.js +89 -0
- data/public/libs/codemirror/addon/search/match-highlighter.js +60 -0
- data/public/libs/codemirror/addon/search/search.js +131 -0
- data/public/libs/codemirror/addon/search/searchcursor.js +133 -0
- data/public/libs/codemirror/addon/selection/active-line.js +39 -0
- data/public/libs/codemirror/addon/selection/mark-selection.js +34 -0
- data/public/libs/codemirror/bin/compress +91 -0
- data/public/libs/codemirror/bin/lint +11 -0
- data/public/libs/codemirror/demo/activeline.html +70 -0
- data/public/libs/codemirror/demo/bidi.html +61 -0
- data/public/libs/codemirror/demo/btree.html +87 -0
- data/public/libs/codemirror/demo/buffers.html +98 -0
- data/public/libs/codemirror/demo/changemode.html +50 -0
- data/public/libs/codemirror/demo/closebrackets.html +63 -0
- data/public/libs/codemirror/demo/closetag.html +37 -0
- data/public/libs/codemirror/demo/complete.html +70 -0
- data/public/libs/codemirror/demo/emacs.html +60 -0
- data/public/libs/codemirror/demo/folding.html +69 -0
- data/public/libs/codemirror/demo/fullscreen.html +147 -0
- data/public/libs/codemirror/demo/html5complete.html +92 -0
- data/public/libs/codemirror/demo/indentwrap.html +49 -0
- data/public/libs/codemirror/demo/lint.html +90 -0
- data/public/libs/codemirror/demo/loadmode.html +40 -0
- data/public/libs/codemirror/demo/marker.html +59 -0
- data/public/libs/codemirror/demo/markselection.html +36 -0
- data/public/libs/codemirror/demo/matchhighlighter.html +38 -0
- data/public/libs/codemirror/demo/multiplex.html +60 -0
- data/public/libs/codemirror/demo/mustache.html +59 -0
- data/public/libs/codemirror/demo/placeholder.html +36 -0
- data/public/libs/codemirror/demo/preview.html +76 -0
- data/public/libs/codemirror/demo/resize.html +49 -0
- data/public/libs/codemirror/demo/runmode.html +50 -0
- data/public/libs/codemirror/demo/search.html +85 -0
- data/public/libs/codemirror/demo/spanaffectswrapping_shim.html +73 -0
- data/public/libs/codemirror/demo/theme.html +89 -0
- data/public/libs/codemirror/demo/variableheight.html +52 -0
- data/public/libs/codemirror/demo/vim.html +65 -0
- data/public/libs/codemirror/demo/visibletabs.html +53 -0
- data/public/libs/codemirror/demo/widget.html +74 -0
- data/public/libs/codemirror/demo/xmlcomplete.html +81 -0
- data/public/libs/codemirror/index.html +487 -0
- data/public/libs/codemirror/keymap/emacs.js +30 -0
- data/public/libs/codemirror/keymap/vim.js +3044 -0
- data/public/libs/codemirror/lib/codemirror.css +253 -0
- data/public/libs/codemirror/lib/codemirror.js +5585 -0
- data/public/libs/codemirror/mode/apl/apl.js +160 -0
- data/public/libs/codemirror/mode/apl/index.html +61 -0
- data/public/libs/codemirror/mode/asterisk/asterisk.js +183 -0
- data/public/libs/codemirror/mode/asterisk/index.html +142 -0
- data/public/libs/codemirror/mode/clike/clike.js +302 -0
- data/public/libs/codemirror/mode/clike/index.html +103 -0
- data/public/libs/codemirror/mode/clike/scala.html +767 -0
- data/public/libs/codemirror/mode/clojure/clojure.js +222 -0
- data/public/libs/codemirror/mode/clojure/index.html +76 -0
- data/public/libs/codemirror/mode/coffeescript/LICENSE +22 -0
- data/public/libs/codemirror/mode/coffeescript/coffeescript.js +346 -0
- data/public/libs/codemirror/mode/coffeescript/index.html +728 -0
- data/public/libs/codemirror/mode/commonlisp/commonlisp.js +101 -0
- data/public/libs/codemirror/mode/commonlisp/index.html +165 -0
- data/public/libs/codemirror/mode/css/css.js +567 -0
- data/public/libs/codemirror/mode/css/index.html +58 -0
- data/public/libs/codemirror/mode/css/scss.html +145 -0
- data/public/libs/codemirror/mode/css/scss_test.js +80 -0
- data/public/libs/codemirror/mode/css/test.js +113 -0
- data/public/libs/codemirror/mode/d/d.js +205 -0
- data/public/libs/codemirror/mode/d/index.html +262 -0
- data/public/libs/codemirror/mode/diff/diff.js +32 -0
- data/public/libs/codemirror/mode/diff/index.html +105 -0
- data/public/libs/codemirror/mode/ecl/ecl.js +192 -0
- data/public/libs/codemirror/mode/ecl/index.html +39 -0
- data/public/libs/codemirror/mode/erlang/erlang.js +463 -0
- data/public/libs/codemirror/mode/erlang/index.html +64 -0
- data/public/libs/codemirror/mode/gas/gas.js +326 -0
- data/public/libs/codemirror/mode/gas/index.html +57 -0
- data/public/libs/codemirror/mode/gfm/gfm.js +96 -0
- data/public/libs/codemirror/mode/gfm/index.html +74 -0
- data/public/libs/codemirror/mode/gfm/test.js +112 -0
- data/public/libs/codemirror/mode/go/go.js +165 -0
- data/public/libs/codemirror/mode/go/index.html +74 -0
- data/public/libs/codemirror/mode/groovy/groovy.js +210 -0
- data/public/libs/codemirror/mode/groovy/index.html +73 -0
- data/public/libs/codemirror/mode/haskell/haskell.js +242 -0
- data/public/libs/codemirror/mode/haskell/index.html +62 -0
- data/public/libs/codemirror/mode/haxe/haxe.js +429 -0
- data/public/libs/codemirror/mode/haxe/index.html +90 -0
- data/public/libs/codemirror/mode/htmlembedded/htmlembedded.js +73 -0
- data/public/libs/codemirror/mode/htmlembedded/index.html +49 -0
- data/public/libs/codemirror/mode/htmlmixed/htmlmixed.js +104 -0
- data/public/libs/codemirror/mode/htmlmixed/index.html +73 -0
- data/public/libs/codemirror/mode/http/http.js +98 -0
- data/public/libs/codemirror/mode/http/index.html +32 -0
- data/public/libs/codemirror/mode/javascript/index.html +92 -0
- data/public/libs/codemirror/mode/javascript/javascript.js +467 -0
- data/public/libs/codemirror/mode/javascript/typescript.html +48 -0
- data/public/libs/codemirror/mode/jinja2/index.html +38 -0
- data/public/libs/codemirror/mode/jinja2/jinja2.js +42 -0
- data/public/libs/codemirror/mode/less/index.html +741 -0
- data/public/libs/codemirror/mode/less/less.js +266 -0
- data/public/libs/codemirror/mode/livescript/LICENSE +23 -0
- data/public/libs/codemirror/mode/livescript/index.html +446 -0
- data/public/libs/codemirror/mode/livescript/livescript.js +267 -0
- data/public/libs/codemirror/mode/livescript/livescript.ls +266 -0
- data/public/libs/codemirror/mode/lua/index.html +74 -0
- data/public/libs/codemirror/mode/lua/lua.js +140 -0
- data/public/libs/codemirror/mode/markdown/index.html +344 -0
- data/public/libs/codemirror/mode/markdown/markdown.js +526 -0
- data/public/libs/codemirror/mode/markdown/test.js +636 -0
- data/public/libs/codemirror/mode/meta.js +75 -0
- data/public/libs/codemirror/mode/mirc/index.html +149 -0
- data/public/libs/codemirror/mode/mirc/mirc.js +177 -0
- data/public/libs/codemirror/mode/ntriples/index.html +33 -0
- data/public/libs/codemirror/mode/ntriples/ntriples.js +170 -0
- data/public/libs/codemirror/mode/ocaml/index.html +131 -0
- data/public/libs/codemirror/mode/ocaml/ocaml.js +113 -0
- data/public/libs/codemirror/mode/pascal/LICENSE +7 -0
- data/public/libs/codemirror/mode/pascal/index.html +48 -0
- data/public/libs/codemirror/mode/pascal/pascal.js +94 -0
- data/public/libs/codemirror/mode/perl/LICENSE +19 -0
- data/public/libs/codemirror/mode/perl/index.html +62 -0
- data/public/libs/codemirror/mode/perl/perl.js +816 -0
- data/public/libs/codemirror/mode/php/index.html +51 -0
- data/public/libs/codemirror/mode/php/php.js +129 -0
- data/public/libs/codemirror/mode/pig/index.html +42 -0
- data/public/libs/codemirror/mode/pig/pig.js +171 -0
- data/public/libs/codemirror/mode/properties/index.html +41 -0
- data/public/libs/codemirror/mode/properties/properties.js +63 -0
- data/public/libs/codemirror/mode/python/LICENSE.txt +21 -0
- data/public/libs/codemirror/mode/python/index.html +135 -0
- data/public/libs/codemirror/mode/python/python.js +340 -0
- data/public/libs/codemirror/mode/q/index.html +131 -0
- data/public/libs/codemirror/mode/q/q.js +124 -0
- data/public/libs/codemirror/mode/r/LICENSE +24 -0
- data/public/libs/codemirror/mode/r/index.html +74 -0
- data/public/libs/codemirror/mode/r/r.js +141 -0
- data/public/libs/codemirror/mode/rpm/changes/changes.js +19 -0
- data/public/libs/codemirror/mode/rpm/changes/index.html +53 -0
- data/public/libs/codemirror/mode/rpm/spec/index.html +99 -0
- data/public/libs/codemirror/mode/rpm/spec/spec.css +5 -0
- data/public/libs/codemirror/mode/rpm/spec/spec.js +66 -0
- data/public/libs/codemirror/mode/rst/LICENSE.txt +21 -0
- data/public/libs/codemirror/mode/rst/index.html +524 -0
- data/public/libs/codemirror/mode/rst/rst.js +550 -0
- data/public/libs/codemirror/mode/ruby/LICENSE +24 -0
- data/public/libs/codemirror/mode/ruby/index.html +173 -0
- data/public/libs/codemirror/mode/ruby/ruby.js +197 -0
- data/public/libs/codemirror/mode/rust/index.html +48 -0
- data/public/libs/codemirror/mode/rust/rust.js +432 -0
- data/public/libs/codemirror/mode/sass/index.html +54 -0
- data/public/libs/codemirror/mode/sass/sass.js +349 -0
- data/public/libs/codemirror/mode/scheme/index.html +65 -0
- data/public/libs/codemirror/mode/scheme/scheme.js +230 -0
- data/public/libs/codemirror/mode/shell/index.html +51 -0
- data/public/libs/codemirror/mode/shell/shell.js +118 -0
- data/public/libs/codemirror/mode/sieve/LICENSE +19 -0
- data/public/libs/codemirror/mode/sieve/index.html +81 -0
- data/public/libs/codemirror/mode/sieve/sieve.js +183 -0
- data/public/libs/codemirror/mode/smalltalk/index.html +57 -0
- data/public/libs/codemirror/mode/smalltalk/smalltalk.js +141 -0
- data/public/libs/codemirror/mode/smarty/index.html +83 -0
- data/public/libs/codemirror/mode/smarty/smarty.js +148 -0
- data/public/libs/codemirror/mode/sparql/index.html +42 -0
- data/public/libs/codemirror/mode/sparql/sparql.js +143 -0
- data/public/libs/codemirror/mode/sql/index.html +68 -0
- data/public/libs/codemirror/mode/sql/sql.js +268 -0
- data/public/libs/codemirror/mode/stex/index.html +98 -0
- data/public/libs/codemirror/mode/stex/stex.js +246 -0
- data/public/libs/codemirror/mode/stex/test.js +117 -0
- data/public/libs/codemirror/mode/tcl/index.html +129 -0
- data/public/libs/codemirror/mode/tcl/tcl.js +131 -0
- data/public/libs/codemirror/mode/tiddlywiki/index.html +142 -0
- data/public/libs/codemirror/mode/tiddlywiki/tiddlywiki.css +14 -0
- data/public/libs/codemirror/mode/tiddlywiki/tiddlywiki.js +353 -0
- data/public/libs/codemirror/mode/tiki/index.html +81 -0
- data/public/libs/codemirror/mode/tiki/tiki.css +26 -0
- data/public/libs/codemirror/mode/tiki/tiki.js +308 -0
- data/public/libs/codemirror/mode/turtle/index.html +39 -0
- data/public/libs/codemirror/mode/turtle/turtle.js +145 -0
- data/public/libs/codemirror/mode/vb/LICENSE.txt +21 -0
- data/public/libs/codemirror/mode/vb/index.html +88 -0
- data/public/libs/codemirror/mode/vb/vb.js +259 -0
- data/public/libs/codemirror/mode/vbscript/index.html +42 -0
- data/public/libs/codemirror/mode/vbscript/vbscript.js +26 -0
- data/public/libs/codemirror/mode/velocity/index.html +103 -0
- data/public/libs/codemirror/mode/velocity/velocity.js +144 -0
- data/public/libs/codemirror/mode/verilog/index.html +121 -0
- data/public/libs/codemirror/mode/verilog/verilog.js +182 -0
- data/public/libs/codemirror/mode/xml/index.html +45 -0
- data/public/libs/codemirror/mode/xml/xml.js +328 -0
- data/public/libs/codemirror/mode/xquery/LICENSE +20 -0
- data/public/libs/codemirror/mode/xquery/index.html +221 -0
- data/public/libs/codemirror/mode/xquery/test.js +64 -0
- data/public/libs/codemirror/mode/xquery/xquery.js +450 -0
- data/public/libs/codemirror/mode/yaml/index.html +68 -0
- data/public/libs/codemirror/mode/yaml/yaml.js +95 -0
- data/public/libs/codemirror/mode/z80/index.html +39 -0
- data/public/libs/codemirror/mode/z80/z80.js +85 -0
- data/public/libs/codemirror/package.json +21 -0
- data/public/libs/codemirror/test/doc_test.js +329 -0
- data/public/libs/codemirror/test/driver.js +138 -0
- data/public/libs/codemirror/test/index.html +182 -0
- data/public/libs/codemirror/test/lint/acorn.js +1593 -0
- data/public/libs/codemirror/test/lint/lint.js +112 -0
- data/public/libs/codemirror/test/lint/parse-js.js +1372 -0
- data/public/libs/codemirror/test/lint/walk.js +216 -0
- data/public/libs/codemirror/test/mode_test.css +10 -0
- data/public/libs/codemirror/test/mode_test.js +192 -0
- data/public/libs/codemirror/test/phantom_driver.js +31 -0
- data/public/libs/codemirror/test/run.js +33 -0
- data/public/libs/codemirror/test/test.js +1400 -0
- data/public/libs/codemirror/test/vim_test.js +1688 -0
- data/public/libs/codemirror/theme/ambiance-mobile.css +5 -0
- data/public/libs/codemirror/theme/ambiance.css +75 -0
- data/public/libs/codemirror/theme/blackboard.css +25 -0
- data/public/libs/codemirror/theme/cobalt.css +18 -0
- data/public/libs/codemirror/theme/eclipse.css +25 -0
- data/public/libs/codemirror/theme/elegant.css +10 -0
- data/public/libs/codemirror/theme/erlang-dark.css +21 -0
- data/public/libs/codemirror/theme/lesser-dark.css +44 -0
- data/public/libs/codemirror/theme/midnight.css +52 -0
- data/public/libs/codemirror/theme/monokai.css +28 -0
- data/public/libs/codemirror/theme/neat.css +9 -0
- data/public/libs/codemirror/theme/night.css +21 -0
- data/public/libs/codemirror/theme/rubyblue.css +21 -0
- data/public/libs/codemirror/theme/solarized.css +207 -0
- data/public/libs/codemirror/theme/twilight.css +26 -0
- data/public/libs/codemirror/theme/vibrant-ink.css +27 -0
- data/public/libs/codemirror/theme/xq-dark.css +46 -0
- data/public/libs/codemirror/theme/xq-light.css +43 -0
- data/public/libs/font-awesome/css/font-awesome-ie7.css +983 -0
- data/public/libs/font-awesome/css/font-awesome-ie7.min.css +24 -0
- data/public/libs/font-awesome/css/font-awesome.css +1268 -0
- data/public/libs/font-awesome/css/font-awesome.min.css +24 -0
- data/public/libs/font-awesome/font/FontAwesome.otf +0 -0
- data/public/libs/font-awesome/font/fontawesome-webfont.eot +0 -0
- data/public/libs/font-awesome/font/fontawesome-webfont.svg +339 -0
- data/public/libs/font-awesome/font/fontawesome-webfont.ttf +0 -0
- data/public/libs/font-awesome/font/fontawesome-webfont.woff +0 -0
- data/public/libs/font-awesome/less/bootstrap.less +78 -0
- data/public/libs/font-awesome/less/core.less +132 -0
- data/public/libs/font-awesome/less/extras.less +79 -0
- data/public/libs/font-awesome/less/font-awesome-ie7.less +413 -0
- data/public/libs/font-awesome/less/font-awesome.less +32 -0
- data/public/libs/font-awesome/less/icons.less +330 -0
- data/public/libs/font-awesome/less/mixins.less +34 -0
- data/public/libs/font-awesome/less/path.less +15 -0
- data/public/libs/font-awesome/less/variables.less +9 -0
- data/public/libs/jquery-1.10.0.min.js +6 -0
- data/public/libs/jquery-ui.min.js +12 -0
- data/public/libs/jquery.jsPlumb-1.4.0-all.js +9571 -0
- data/public/libs/jquery.livequery.js +226 -0
- data/public/libs/jsPlumbInitializer.js +72 -0
- data/public/libs/jstree/README.txt +10 -0
- data/public/libs/jstree/_demo/_dump.sql +20 -0
- data/public/libs/jstree/_demo/_inc/__mysql_errors.log +0 -0
- data/public/libs/jstree/_demo/_inc/class._database.php +146 -0
- data/public/libs/jstree/_demo/_inc/class._database_i.php +152 -0
- data/public/libs/jstree/_demo/_inc/class.tree.php +602 -0
- data/public/libs/jstree/_demo/_install.txt +6 -0
- data/public/libs/jstree/_demo/config.php +14 -0
- data/public/libs/jstree/_demo/file.png +0 -0
- data/public/libs/jstree/_demo/folder.png +0 -0
- data/public/libs/jstree/_demo/index.html +461 -0
- data/public/libs/jstree/_demo/root.png +0 -0
- data/public/libs/jstree/_demo/server.php +69 -0
- data/public/libs/jstree/_docs/!style.css +48 -0
- data/public/libs/jstree/_docs/_drive.png +0 -0
- data/public/libs/jstree/_docs/_html_data.html +2 -0
- data/public/libs/jstree/_docs/_json_data.json +4 -0
- data/public/libs/jstree/_docs/_search_data.json +6 -0
- data/public/libs/jstree/_docs/_search_result.json +1 -0
- data/public/libs/jstree/_docs/_xml_flat.xml +12 -0
- data/public/libs/jstree/_docs/_xml_nest.xml +18 -0
- data/public/libs/jstree/_docs/checkbox.html +171 -0
- data/public/libs/jstree/_docs/contextmenu.html +121 -0
- data/public/libs/jstree/_docs/cookies.html +97 -0
- data/public/libs/jstree/_docs/core.html +689 -0
- data/public/libs/jstree/_docs/crrm.html +316 -0
- data/public/libs/jstree/_docs/dnd.html +199 -0
- data/public/libs/jstree/_docs/hotkeys.html +82 -0
- data/public/libs/jstree/_docs/html_data.html +175 -0
- data/public/libs/jstree/_docs/index.html +86 -0
- data/public/libs/jstree/_docs/json_data.html +249 -0
- data/public/libs/jstree/_docs/languages.html +152 -0
- data/public/libs/jstree/_docs/logo.png +0 -0
- data/public/libs/jstree/_docs/search.html +153 -0
- data/public/libs/jstree/_docs/sort.html +85 -0
- data/public/libs/jstree/_docs/syntax/!script.js +2232 -0
- data/public/libs/jstree/_docs/syntax/!style.css +511 -0
- data/public/libs/jstree/_docs/syntax/clipboard.swf +0 -0
- data/public/libs/jstree/_docs/syntax/help.png +0 -0
- data/public/libs/jstree/_docs/syntax/magnifier.png +0 -0
- data/public/libs/jstree/_docs/syntax/page_white_code.png +0 -0
- data/public/libs/jstree/_docs/syntax/page_white_copy.png +0 -0
- data/public/libs/jstree/_docs/syntax/printer.png +0 -0
- data/public/libs/jstree/_docs/syntax/wrapping.png +0 -0
- data/public/libs/jstree/_docs/themeroller.html +107 -0
- data/public/libs/jstree/_docs/themes.html +127 -0
- data/public/libs/jstree/_docs/types.html +178 -0
- data/public/libs/jstree/_docs/ui.html +197 -0
- data/public/libs/jstree/_docs/unique.html +85 -0
- data/public/libs/jstree/_docs/xml_data.html +218 -0
- data/public/libs/jstree/_lib/jquery.cookie.js +96 -0
- data/public/libs/jstree/_lib/jquery.hotkeys.js +99 -0
- data/public/libs/jstree/_lib/jquery.js +5 -0
- data/public/libs/jstree/jquery.jstree.js +4564 -0
- data/public/libs/jstree/themes/apple/bg.jpg +0 -0
- data/public/libs/jstree/themes/apple/d.png +0 -0
- data/public/libs/jstree/themes/apple/dot_for_ie.gif +0 -0
- data/public/libs/jstree/themes/apple/style.css +61 -0
- data/public/libs/jstree/themes/apple/throbber.gif +0 -0
- data/public/libs/jstree/themes/classic/d.gif +0 -0
- data/public/libs/jstree/themes/classic/d.png +0 -0
- data/public/libs/jstree/themes/classic/dot_for_ie.gif +0 -0
- data/public/libs/jstree/themes/classic/style.css +77 -0
- data/public/libs/jstree/themes/classic/throbber.gif +0 -0
- data/public/libs/jstree/themes/default-rtl/d.gif +0 -0
- data/public/libs/jstree/themes/default-rtl/d.png +0 -0
- data/public/libs/jstree/themes/default-rtl/dots.gif +0 -0
- data/public/libs/jstree/themes/default-rtl/style.css +84 -0
- data/public/libs/jstree/themes/default-rtl/throbber.gif +0 -0
- data/public/libs/jstree/themes/default/d.gif +0 -0
- data/public/libs/jstree/themes/default/d.png +0 -0
- data/public/libs/jstree/themes/default/style.css +74 -0
- data/public/libs/jstree/themes/default/throbber.gif +0 -0
- data/public/themes/geo-bootstrap/README.md +25 -0
- data/public/themes/geo-bootstrap/img/flames.gif +0 -0
- data/public/themes/geo-bootstrap/img/glyphicons-halflings-white.png +0 -0
- data/public/themes/geo-bootstrap/img/glyphicons-halflings.png +0 -0
- data/public/themes/geo-bootstrap/img/microfab.gif +0 -0
- data/public/themes/geo-bootstrap/img/progress.gif +0 -0
- data/public/themes/geo-bootstrap/img/rainbow.gif +0 -0
- data/public/themes/geo-bootstrap/img/stars.gif +0 -0
- data/public/themes/geo-bootstrap/img/test/7upspot.gif +0 -0
- data/public/themes/geo-bootstrap/img/test/americanflag.gif +0 -0
- data/public/themes/geo-bootstrap/img/test/community.gif +0 -0
- data/public/themes/geo-bootstrap/img/test/computer-01.gif +0 -0
- data/public/themes/geo-bootstrap/img/test/computer.gif +0 -0
- data/public/themes/geo-bootstrap/img/test/construction.gif +0 -0
- data/public/themes/geo-bootstrap/img/test/counter.gif +0 -0
- data/public/themes/geo-bootstrap/img/test/counter2.gif +0 -0
- data/public/themes/geo-bootstrap/img/test/divider.gif +0 -0
- data/public/themes/geo-bootstrap/img/test/divider1.gif +0 -0
- data/public/themes/geo-bootstrap/img/test/divider2.gif +0 -0
- data/public/themes/geo-bootstrap/img/test/divider3.gif +0 -0
- data/public/themes/geo-bootstrap/img/test/divider4.gif +0 -0
- data/public/themes/geo-bootstrap/img/test/drudgesiren.gif +0 -0
- data/public/themes/geo-bootstrap/img/test/emailme.gif +0 -0
- data/public/themes/geo-bootstrap/img/test/funky.gif +0 -0
- data/public/themes/geo-bootstrap/img/test/geocities.jpg +0 -0
- data/public/themes/geo-bootstrap/img/test/hacker.gif +0 -0
- data/public/themes/geo-bootstrap/img/test/heart.gif +0 -0
- data/public/themes/geo-bootstrap/img/test/hot.gif +0 -0
- data/public/themes/geo-bootstrap/img/test/ie_logo.gif +0 -0
- data/public/themes/geo-bootstrap/img/test/mailkitten.gif +0 -0
- data/public/themes/geo-bootstrap/img/test/mchammer.gif +0 -0
- data/public/themes/geo-bootstrap/img/test/new.gif +0 -0
- data/public/themes/geo-bootstrap/img/test/new2.gif +0 -0
- data/public/themes/geo-bootstrap/img/test/noframes.gif +0 -0
- data/public/themes/geo-bootstrap/img/test/notepad.gif +0 -0
- data/public/themes/geo-bootstrap/img/test/ns_logo.gif +0 -0
- data/public/themes/geo-bootstrap/img/test/sign-in.gif +0 -0
- data/public/themes/geo-bootstrap/img/test/spinningearth.gif +0 -0
- data/public/themes/geo-bootstrap/img/test/underconstruction.gif +0 -0
- data/public/themes/geo-bootstrap/img/test/wabwalk.gif +0 -0
- data/public/themes/geo-bootstrap/img/test/webtrips.gif +0 -0
- data/public/themes/geo-bootstrap/img/test/yahooweek.gif +0 -0
- data/public/themes/geo-bootstrap/package.json +21 -0
- data/public/themes/geo-bootstrap/swatch/bootstrap-responsive.css +1109 -0
- data/public/themes/geo-bootstrap/swatch/bootstrap-responsive.min.css +9 -0
- data/public/themes/geo-bootstrap/swatch/bootstrap.css +6462 -0
- data/public/themes/geo-bootstrap/swatch/bootstrap.min.css +9 -0
- metadata +791 -0
@@ -0,0 +1,302 @@
|
|
1
|
+
CodeMirror.defineMode("clike", function(config, parserConfig) {
|
2
|
+
var indentUnit = config.indentUnit,
|
3
|
+
statementIndentUnit = parserConfig.statementIndentUnit || indentUnit,
|
4
|
+
dontAlignCalls = parserConfig.dontAlignCalls,
|
5
|
+
keywords = parserConfig.keywords || {},
|
6
|
+
builtin = parserConfig.builtin || {},
|
7
|
+
blockKeywords = parserConfig.blockKeywords || {},
|
8
|
+
atoms = parserConfig.atoms || {},
|
9
|
+
hooks = parserConfig.hooks || {},
|
10
|
+
multiLineStrings = parserConfig.multiLineStrings;
|
11
|
+
var isOperatorChar = /[+\-*&%=<>!?|\/]/;
|
12
|
+
|
13
|
+
var curPunc;
|
14
|
+
|
15
|
+
function tokenBase(stream, state) {
|
16
|
+
var ch = stream.next();
|
17
|
+
if (hooks[ch]) {
|
18
|
+
var result = hooks[ch](stream, state);
|
19
|
+
if (result !== false) return result;
|
20
|
+
}
|
21
|
+
if (ch == '"' || ch == "'") {
|
22
|
+
state.tokenize = tokenString(ch);
|
23
|
+
return state.tokenize(stream, state);
|
24
|
+
}
|
25
|
+
if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
|
26
|
+
curPunc = ch;
|
27
|
+
return null;
|
28
|
+
}
|
29
|
+
if (/\d/.test(ch)) {
|
30
|
+
stream.eatWhile(/[\w\.]/);
|
31
|
+
return "number";
|
32
|
+
}
|
33
|
+
if (ch == "/") {
|
34
|
+
if (stream.eat("*")) {
|
35
|
+
state.tokenize = tokenComment;
|
36
|
+
return tokenComment(stream, state);
|
37
|
+
}
|
38
|
+
if (stream.eat("/")) {
|
39
|
+
stream.skipToEnd();
|
40
|
+
return "comment";
|
41
|
+
}
|
42
|
+
}
|
43
|
+
if (isOperatorChar.test(ch)) {
|
44
|
+
stream.eatWhile(isOperatorChar);
|
45
|
+
return "operator";
|
46
|
+
}
|
47
|
+
stream.eatWhile(/[\w\$_]/);
|
48
|
+
var cur = stream.current();
|
49
|
+
if (keywords.propertyIsEnumerable(cur)) {
|
50
|
+
if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
|
51
|
+
return "keyword";
|
52
|
+
}
|
53
|
+
if (builtin.propertyIsEnumerable(cur)) {
|
54
|
+
if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
|
55
|
+
return "builtin";
|
56
|
+
}
|
57
|
+
if (atoms.propertyIsEnumerable(cur)) return "atom";
|
58
|
+
return "variable";
|
59
|
+
}
|
60
|
+
|
61
|
+
function tokenString(quote) {
|
62
|
+
return function(stream, state) {
|
63
|
+
var escaped = false, next, end = false;
|
64
|
+
while ((next = stream.next()) != null) {
|
65
|
+
if (next == quote && !escaped) {end = true; break;}
|
66
|
+
escaped = !escaped && next == "\\";
|
67
|
+
}
|
68
|
+
if (end || !(escaped || multiLineStrings))
|
69
|
+
state.tokenize = null;
|
70
|
+
return "string";
|
71
|
+
};
|
72
|
+
}
|
73
|
+
|
74
|
+
function tokenComment(stream, state) {
|
75
|
+
var maybeEnd = false, ch;
|
76
|
+
while (ch = stream.next()) {
|
77
|
+
if (ch == "/" && maybeEnd) {
|
78
|
+
state.tokenize = null;
|
79
|
+
break;
|
80
|
+
}
|
81
|
+
maybeEnd = (ch == "*");
|
82
|
+
}
|
83
|
+
return "comment";
|
84
|
+
}
|
85
|
+
|
86
|
+
function Context(indented, column, type, align, prev) {
|
87
|
+
this.indented = indented;
|
88
|
+
this.column = column;
|
89
|
+
this.type = type;
|
90
|
+
this.align = align;
|
91
|
+
this.prev = prev;
|
92
|
+
}
|
93
|
+
function pushContext(state, col, type) {
|
94
|
+
var indent = state.indented;
|
95
|
+
if (state.context && state.context.type == "statement")
|
96
|
+
indent = state.context.indented;
|
97
|
+
return state.context = new Context(indent, col, type, null, state.context);
|
98
|
+
}
|
99
|
+
function popContext(state) {
|
100
|
+
var t = state.context.type;
|
101
|
+
if (t == ")" || t == "]" || t == "}")
|
102
|
+
state.indented = state.context.indented;
|
103
|
+
return state.context = state.context.prev;
|
104
|
+
}
|
105
|
+
|
106
|
+
// Interface
|
107
|
+
|
108
|
+
return {
|
109
|
+
startState: function(basecolumn) {
|
110
|
+
return {
|
111
|
+
tokenize: null,
|
112
|
+
context: new Context((basecolumn || 0) - indentUnit, 0, "top", false),
|
113
|
+
indented: 0,
|
114
|
+
startOfLine: true
|
115
|
+
};
|
116
|
+
},
|
117
|
+
|
118
|
+
token: function(stream, state) {
|
119
|
+
var ctx = state.context;
|
120
|
+
if (stream.sol()) {
|
121
|
+
if (ctx.align == null) ctx.align = false;
|
122
|
+
state.indented = stream.indentation();
|
123
|
+
state.startOfLine = true;
|
124
|
+
}
|
125
|
+
if (stream.eatSpace()) return null;
|
126
|
+
curPunc = null;
|
127
|
+
var style = (state.tokenize || tokenBase)(stream, state);
|
128
|
+
if (style == "comment" || style == "meta") return style;
|
129
|
+
if (ctx.align == null) ctx.align = true;
|
130
|
+
|
131
|
+
if ((curPunc == ";" || curPunc == ":" || curPunc == ",") && ctx.type == "statement") popContext(state);
|
132
|
+
else if (curPunc == "{") pushContext(state, stream.column(), "}");
|
133
|
+
else if (curPunc == "[") pushContext(state, stream.column(), "]");
|
134
|
+
else if (curPunc == "(") pushContext(state, stream.column(), ")");
|
135
|
+
else if (curPunc == "}") {
|
136
|
+
while (ctx.type == "statement") ctx = popContext(state);
|
137
|
+
if (ctx.type == "}") ctx = popContext(state);
|
138
|
+
while (ctx.type == "statement") ctx = popContext(state);
|
139
|
+
}
|
140
|
+
else if (curPunc == ctx.type) popContext(state);
|
141
|
+
else if (((ctx.type == "}" || ctx.type == "top") && curPunc != ';') || (ctx.type == "statement" && curPunc == "newstatement"))
|
142
|
+
pushContext(state, stream.column(), "statement");
|
143
|
+
state.startOfLine = false;
|
144
|
+
return style;
|
145
|
+
},
|
146
|
+
|
147
|
+
indent: function(state, textAfter) {
|
148
|
+
if (state.tokenize != tokenBase && state.tokenize != null) return CodeMirror.Pass;
|
149
|
+
var ctx = state.context, firstChar = textAfter && textAfter.charAt(0);
|
150
|
+
if (ctx.type == "statement" && firstChar == "}") ctx = ctx.prev;
|
151
|
+
var closing = firstChar == ctx.type;
|
152
|
+
if (ctx.type == "statement") return ctx.indented + (firstChar == "{" ? 0 : statementIndentUnit);
|
153
|
+
else if (dontAlignCalls && ctx.type == ")" && !closing) return ctx.indented + statementIndentUnit;
|
154
|
+
else if (ctx.align) return ctx.column + (closing ? 0 : 1);
|
155
|
+
else return ctx.indented + (closing ? 0 : indentUnit);
|
156
|
+
},
|
157
|
+
|
158
|
+
electricChars: "{}"
|
159
|
+
};
|
160
|
+
});
|
161
|
+
|
162
|
+
(function() {
|
163
|
+
function words(str) {
|
164
|
+
var obj = {}, words = str.split(" ");
|
165
|
+
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
|
166
|
+
return obj;
|
167
|
+
}
|
168
|
+
var cKeywords = "auto if break int case long char register continue return default short do sizeof " +
|
169
|
+
"double static else struct entry switch extern typedef float union for unsigned " +
|
170
|
+
"goto while enum void const signed volatile";
|
171
|
+
|
172
|
+
function cppHook(stream, state) {
|
173
|
+
if (!state.startOfLine) return false;
|
174
|
+
for (;;) {
|
175
|
+
if (stream.skipTo("\\")) {
|
176
|
+
stream.next();
|
177
|
+
if (stream.eol()) {
|
178
|
+
state.tokenize = cppHook;
|
179
|
+
break;
|
180
|
+
}
|
181
|
+
} else {
|
182
|
+
stream.skipToEnd();
|
183
|
+
state.tokenize = null;
|
184
|
+
break;
|
185
|
+
}
|
186
|
+
}
|
187
|
+
return "meta";
|
188
|
+
}
|
189
|
+
|
190
|
+
// C#-style strings where "" escapes a quote.
|
191
|
+
function tokenAtString(stream, state) {
|
192
|
+
var next;
|
193
|
+
while ((next = stream.next()) != null) {
|
194
|
+
if (next == '"' && !stream.eat('"')) {
|
195
|
+
state.tokenize = null;
|
196
|
+
break;
|
197
|
+
}
|
198
|
+
}
|
199
|
+
return "string";
|
200
|
+
}
|
201
|
+
|
202
|
+
function mimes(ms, mode) {
|
203
|
+
for (var i = 0; i < ms.length; ++i) CodeMirror.defineMIME(ms[i], mode);
|
204
|
+
}
|
205
|
+
|
206
|
+
mimes(["text/x-csrc", "text/x-c", "text/x-chdr"], {
|
207
|
+
name: "clike",
|
208
|
+
keywords: words(cKeywords),
|
209
|
+
blockKeywords: words("case do else for if switch while struct"),
|
210
|
+
atoms: words("null"),
|
211
|
+
hooks: {"#": cppHook}
|
212
|
+
});
|
213
|
+
mimes(["text/x-c++src", "text/x-c++hdr"], {
|
214
|
+
name: "clike",
|
215
|
+
keywords: words(cKeywords + " asm dynamic_cast namespace reinterpret_cast try bool explicit new " +
|
216
|
+
"static_cast typeid catch operator template typename class friend private " +
|
217
|
+
"this using const_cast inline public throw virtual delete mutable protected " +
|
218
|
+
"wchar_t"),
|
219
|
+
blockKeywords: words("catch class do else finally for if struct switch try while"),
|
220
|
+
atoms: words("true false null"),
|
221
|
+
hooks: {"#": cppHook}
|
222
|
+
});
|
223
|
+
CodeMirror.defineMIME("text/x-java", {
|
224
|
+
name: "clike",
|
225
|
+
keywords: words("abstract assert boolean break byte case catch char class const continue default " +
|
226
|
+
"do double else enum extends final finally float for goto if implements import " +
|
227
|
+
"instanceof int interface long native new package private protected public " +
|
228
|
+
"return short static strictfp super switch synchronized this throw throws transient " +
|
229
|
+
"try void volatile while"),
|
230
|
+
blockKeywords: words("catch class do else finally for if switch try while"),
|
231
|
+
atoms: words("true false null"),
|
232
|
+
hooks: {
|
233
|
+
"@": function(stream) {
|
234
|
+
stream.eatWhile(/[\w\$_]/);
|
235
|
+
return "meta";
|
236
|
+
}
|
237
|
+
}
|
238
|
+
});
|
239
|
+
CodeMirror.defineMIME("text/x-csharp", {
|
240
|
+
name: "clike",
|
241
|
+
keywords: words("abstract as base break case catch checked class const continue" +
|
242
|
+
" default delegate do else enum event explicit extern finally fixed for" +
|
243
|
+
" foreach goto if implicit in interface internal is lock namespace new" +
|
244
|
+
" operator out override params private protected public readonly ref return sealed" +
|
245
|
+
" sizeof stackalloc static struct switch this throw try typeof unchecked" +
|
246
|
+
" unsafe using virtual void volatile while add alias ascending descending dynamic from get" +
|
247
|
+
" global group into join let orderby partial remove select set value var yield"),
|
248
|
+
blockKeywords: words("catch class do else finally for foreach if struct switch try while"),
|
249
|
+
builtin: words("Boolean Byte Char DateTime DateTimeOffset Decimal Double" +
|
250
|
+
" Guid Int16 Int32 Int64 Object SByte Single String TimeSpan UInt16 UInt32" +
|
251
|
+
" UInt64 bool byte char decimal double short int long object" +
|
252
|
+
" sbyte float string ushort uint ulong"),
|
253
|
+
atoms: words("true false null"),
|
254
|
+
hooks: {
|
255
|
+
"@": function(stream, state) {
|
256
|
+
if (stream.eat('"')) {
|
257
|
+
state.tokenize = tokenAtString;
|
258
|
+
return tokenAtString(stream, state);
|
259
|
+
}
|
260
|
+
stream.eatWhile(/[\w\$_]/);
|
261
|
+
return "meta";
|
262
|
+
}
|
263
|
+
}
|
264
|
+
});
|
265
|
+
CodeMirror.defineMIME("text/x-scala", {
|
266
|
+
name: "clike",
|
267
|
+
keywords: words(
|
268
|
+
|
269
|
+
/* scala */
|
270
|
+
"abstract case catch class def do else extends false final finally for forSome if " +
|
271
|
+
"implicit import lazy match new null object override package private protected return " +
|
272
|
+
"sealed super this throw trait try trye type val var while with yield _ : = => <- <: " +
|
273
|
+
"<% >: # @ " +
|
274
|
+
|
275
|
+
/* package scala */
|
276
|
+
"assert assume require print println printf readLine readBoolean readByte readShort " +
|
277
|
+
"readChar readInt readLong readFloat readDouble " +
|
278
|
+
|
279
|
+
"AnyVal App Application Array BufferedIterator BigDecimal BigInt Char Console Either " +
|
280
|
+
"Enumeration Equiv Error Exception Fractional Function IndexedSeq Integral Iterable " +
|
281
|
+
"Iterator List Map Numeric Nil NotNull Option Ordered Ordering PartialFunction PartialOrdering " +
|
282
|
+
"Product Proxy Range Responder Seq Serializable Set Specializable Stream StringBuilder " +
|
283
|
+
"StringContext Symbol Throwable Traversable TraversableOnce Tuple Unit Vector :: #:: " +
|
284
|
+
|
285
|
+
/* package java.lang */
|
286
|
+
"Boolean Byte Character CharSequence Class ClassLoader Cloneable Comparable " +
|
287
|
+
"Compiler Double Exception Float Integer Long Math Number Object Package Pair Process " +
|
288
|
+
"Runtime Runnable SecurityManager Short StackTraceElement StrictMath String " +
|
289
|
+
"StringBuffer System Thread ThreadGroup ThreadLocal Throwable Triple Void"
|
290
|
+
|
291
|
+
|
292
|
+
),
|
293
|
+
blockKeywords: words("catch class do else finally for forSome if match switch try while"),
|
294
|
+
atoms: words("true false null"),
|
295
|
+
hooks: {
|
296
|
+
"@": function(stream) {
|
297
|
+
stream.eatWhile(/[\w\$_]/);
|
298
|
+
return "meta";
|
299
|
+
}
|
300
|
+
}
|
301
|
+
});
|
302
|
+
}());
|
@@ -0,0 +1,103 @@
|
|
1
|
+
<!doctype html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<title>CodeMirror: C-like mode</title>
|
6
|
+
<link rel="stylesheet" href="../../lib/codemirror.css">
|
7
|
+
<script src="../../lib/codemirror.js"></script>
|
8
|
+
<script src="../../addon/edit/matchbrackets.js"></script>
|
9
|
+
<script src="clike.js"></script>
|
10
|
+
<link rel="stylesheet" href="../../doc/docs.css">
|
11
|
+
<style>.CodeMirror {border: 2px inset #dee;}</style>
|
12
|
+
</head>
|
13
|
+
<body>
|
14
|
+
<h1>CodeMirror: C-like mode</h1>
|
15
|
+
|
16
|
+
<form><textarea id="code" name="code">
|
17
|
+
/* C demo code */
|
18
|
+
|
19
|
+
#include <zmq.h>
|
20
|
+
#include <pthread.h>
|
21
|
+
#include <semaphore.h>
|
22
|
+
#include <time.h>
|
23
|
+
#include <stdio.h>
|
24
|
+
#include <fcntl.h>
|
25
|
+
#include <malloc.h>
|
26
|
+
|
27
|
+
typedef struct {
|
28
|
+
void* arg_socket;
|
29
|
+
zmq_msg_t* arg_msg;
|
30
|
+
char* arg_string;
|
31
|
+
unsigned long arg_len;
|
32
|
+
int arg_int, arg_command;
|
33
|
+
|
34
|
+
int signal_fd;
|
35
|
+
int pad;
|
36
|
+
void* context;
|
37
|
+
sem_t sem;
|
38
|
+
} acl_zmq_context;
|
39
|
+
|
40
|
+
#define p(X) (context->arg_##X)
|
41
|
+
|
42
|
+
void* zmq_thread(void* context_pointer) {
|
43
|
+
acl_zmq_context* context = (acl_zmq_context*)context_pointer;
|
44
|
+
char ok = 'K', err = 'X';
|
45
|
+
int res;
|
46
|
+
|
47
|
+
while (1) {
|
48
|
+
while ((res = sem_wait(&context->sem)) == EINTR);
|
49
|
+
if (res) {write(context->signal_fd, &err, 1); goto cleanup;}
|
50
|
+
switch(p(command)) {
|
51
|
+
case 0: goto cleanup;
|
52
|
+
case 1: p(socket) = zmq_socket(context->context, p(int)); break;
|
53
|
+
case 2: p(int) = zmq_close(p(socket)); break;
|
54
|
+
case 3: p(int) = zmq_bind(p(socket), p(string)); break;
|
55
|
+
case 4: p(int) = zmq_connect(p(socket), p(string)); break;
|
56
|
+
case 5: p(int) = zmq_getsockopt(p(socket), p(int), (void*)p(string), &p(len)); break;
|
57
|
+
case 6: p(int) = zmq_setsockopt(p(socket), p(int), (void*)p(string), p(len)); break;
|
58
|
+
case 7: p(int) = zmq_send(p(socket), p(msg), p(int)); break;
|
59
|
+
case 8: p(int) = zmq_recv(p(socket), p(msg), p(int)); break;
|
60
|
+
case 9: p(int) = zmq_poll(p(socket), p(int), p(len)); break;
|
61
|
+
}
|
62
|
+
p(command) = errno;
|
63
|
+
write(context->signal_fd, &ok, 1);
|
64
|
+
}
|
65
|
+
cleanup:
|
66
|
+
close(context->signal_fd);
|
67
|
+
free(context_pointer);
|
68
|
+
return 0;
|
69
|
+
}
|
70
|
+
|
71
|
+
void* zmq_thread_init(void* zmq_context, int signal_fd) {
|
72
|
+
acl_zmq_context* context = malloc(sizeof(acl_zmq_context));
|
73
|
+
pthread_t thread;
|
74
|
+
|
75
|
+
context->context = zmq_context;
|
76
|
+
context->signal_fd = signal_fd;
|
77
|
+
sem_init(&context->sem, 1, 0);
|
78
|
+
pthread_create(&thread, 0, &zmq_thread, context);
|
79
|
+
pthread_detach(thread);
|
80
|
+
return context;
|
81
|
+
}
|
82
|
+
</textarea></form>
|
83
|
+
|
84
|
+
<script>
|
85
|
+
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
86
|
+
lineNumbers: true,
|
87
|
+
matchBrackets: true,
|
88
|
+
mode: "text/x-csrc"
|
89
|
+
});
|
90
|
+
</script>
|
91
|
+
|
92
|
+
<p>Simple mode that tries to handle C-like languages as well as it
|
93
|
+
can. Takes two configuration parameters: <code>keywords</code>, an
|
94
|
+
object whose property names are the keywords in the language,
|
95
|
+
and <code>useCPP</code>, which determines whether C preprocessor
|
96
|
+
directives are recognized.</p>
|
97
|
+
|
98
|
+
<p><strong>MIME types defined:</strong> <code>text/x-csrc</code>
|
99
|
+
(C code), <code>text/x-c++src</code> (C++
|
100
|
+
code), <code>text/x-java</code> (Java
|
101
|
+
code), <code>text/x-csharp</code> (C#).</p>
|
102
|
+
</body>
|
103
|
+
</html>
|
@@ -0,0 +1,767 @@
|
|
1
|
+
<!doctype html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<title>CodeMirror: C-like mode</title>
|
6
|
+
<link rel="stylesheet" href="../../lib/codemirror.css">
|
7
|
+
<link rel="stylesheet" href="../../theme/ambiance.css">
|
8
|
+
<script src="../../lib/codemirror.js"></script>
|
9
|
+
<script src="../../addon/edit/matchbrackets.js"></script>
|
10
|
+
<script src="clike.js"></script>
|
11
|
+
<link rel="stylesheet" href="../../doc/docs.css">
|
12
|
+
<style>
|
13
|
+
body
|
14
|
+
{
|
15
|
+
margin: 0;
|
16
|
+
padding: 0;
|
17
|
+
max-width:inherit;
|
18
|
+
height: 100%;
|
19
|
+
}
|
20
|
+
html, form, .CodeMirror, .CodeMirror-scroll
|
21
|
+
{
|
22
|
+
height: 100%;
|
23
|
+
}
|
24
|
+
</style>
|
25
|
+
</head>
|
26
|
+
<body>
|
27
|
+
<form>
|
28
|
+
<textarea id="code" name="code">
|
29
|
+
|
30
|
+
/* __ *\
|
31
|
+
** ________ ___ / / ___ Scala API **
|
32
|
+
** / __/ __// _ | / / / _ | (c) 2003-2011, LAMP/EPFL **
|
33
|
+
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
|
34
|
+
** /____/\___/_/ |_/____/_/ | | **
|
35
|
+
** |/ **
|
36
|
+
\* */
|
37
|
+
|
38
|
+
package scala.collection
|
39
|
+
|
40
|
+
import generic._
|
41
|
+
import mutable.{ Builder, ListBuffer }
|
42
|
+
import annotation.{tailrec, migration, bridge}
|
43
|
+
import annotation.unchecked.{ uncheckedVariance => uV }
|
44
|
+
import parallel.ParIterable
|
45
|
+
|
46
|
+
/** A template trait for traversable collections of type `Traversable[A]`.
|
47
|
+
*
|
48
|
+
* $traversableInfo
|
49
|
+
* @define mutability
|
50
|
+
* @define traversableInfo
|
51
|
+
* This is a base trait of all kinds of $mutability Scala collections. It
|
52
|
+
* implements the behavior common to all collections, in terms of a method
|
53
|
+
* `foreach` with signature:
|
54
|
+
* {{{
|
55
|
+
* def foreach[U](f: Elem => U): Unit
|
56
|
+
* }}}
|
57
|
+
* Collection classes mixing in this trait provide a concrete
|
58
|
+
* `foreach` method which traverses all the
|
59
|
+
* elements contained in the collection, applying a given function to each.
|
60
|
+
* They also need to provide a method `newBuilder`
|
61
|
+
* which creates a builder for collections of the same kind.
|
62
|
+
*
|
63
|
+
* A traversable class might or might not have two properties: strictness
|
64
|
+
* and orderedness. Neither is represented as a type.
|
65
|
+
*
|
66
|
+
* The instances of a strict collection class have all their elements
|
67
|
+
* computed before they can be used as values. By contrast, instances of
|
68
|
+
* a non-strict collection class may defer computation of some of their
|
69
|
+
* elements until after the instance is available as a value.
|
70
|
+
* A typical example of a non-strict collection class is a
|
71
|
+
* <a href="../immutable/Stream.html" target="ContentFrame">
|
72
|
+
* `scala.collection.immutable.Stream`</a>.
|
73
|
+
* A more general class of examples are `TraversableViews`.
|
74
|
+
*
|
75
|
+
* If a collection is an instance of an ordered collection class, traversing
|
76
|
+
* its elements with `foreach` will always visit elements in the
|
77
|
+
* same order, even for different runs of the program. If the class is not
|
78
|
+
* ordered, `foreach` can visit elements in different orders for
|
79
|
+
* different runs (but it will keep the same order in the same run).'
|
80
|
+
*
|
81
|
+
* A typical example of a collection class which is not ordered is a
|
82
|
+
* `HashMap` of objects. The traversal order for hash maps will
|
83
|
+
* depend on the hash codes of its elements, and these hash codes might
|
84
|
+
* differ from one run to the next. By contrast, a `LinkedHashMap`
|
85
|
+
* is ordered because it's `foreach` method visits elements in the
|
86
|
+
* order they were inserted into the `HashMap`.
|
87
|
+
*
|
88
|
+
* @author Martin Odersky
|
89
|
+
* @version 2.8
|
90
|
+
* @since 2.8
|
91
|
+
* @tparam A the element type of the collection
|
92
|
+
* @tparam Repr the type of the actual collection containing the elements.
|
93
|
+
*
|
94
|
+
* @define Coll Traversable
|
95
|
+
* @define coll traversable collection
|
96
|
+
*/
|
97
|
+
trait TraversableLike[+A, +Repr] extends HasNewBuilder[A, Repr]
|
98
|
+
with FilterMonadic[A, Repr]
|
99
|
+
with TraversableOnce[A]
|
100
|
+
with GenTraversableLike[A, Repr]
|
101
|
+
with Parallelizable[A, ParIterable[A]]
|
102
|
+
{
|
103
|
+
self =>
|
104
|
+
|
105
|
+
import Traversable.breaks._
|
106
|
+
|
107
|
+
/** The type implementing this traversable */
|
108
|
+
protected type Self = Repr
|
109
|
+
|
110
|
+
/** The collection of type $coll underlying this `TraversableLike` object.
|
111
|
+
* By default this is implemented as the `TraversableLike` object itself,
|
112
|
+
* but this can be overridden.
|
113
|
+
*/
|
114
|
+
def repr: Repr = this.asInstanceOf[Repr]
|
115
|
+
|
116
|
+
/** The underlying collection seen as an instance of `$Coll`.
|
117
|
+
* By default this is implemented as the current collection object itself,
|
118
|
+
* but this can be overridden.
|
119
|
+
*/
|
120
|
+
protected[this] def thisCollection: Traversable[A] = this.asInstanceOf[Traversable[A]]
|
121
|
+
|
122
|
+
/** A conversion from collections of type `Repr` to `$Coll` objects.
|
123
|
+
* By default this is implemented as just a cast, but this can be overridden.
|
124
|
+
*/
|
125
|
+
protected[this] def toCollection(repr: Repr): Traversable[A] = repr.asInstanceOf[Traversable[A]]
|
126
|
+
|
127
|
+
/** Creates a new builder for this collection type.
|
128
|
+
*/
|
129
|
+
protected[this] def newBuilder: Builder[A, Repr]
|
130
|
+
|
131
|
+
protected[this] def parCombiner = ParIterable.newCombiner[A]
|
132
|
+
|
133
|
+
/** Applies a function `f` to all elements of this $coll.
|
134
|
+
*
|
135
|
+
* Note: this method underlies the implementation of most other bulk operations.
|
136
|
+
* It's important to implement this method in an efficient way.
|
137
|
+
*
|
138
|
+
*
|
139
|
+
* @param f the function that is applied for its side-effect to every element.
|
140
|
+
* The result of function `f` is discarded.
|
141
|
+
*
|
142
|
+
* @tparam U the type parameter describing the result of function `f`.
|
143
|
+
* This result will always be ignored. Typically `U` is `Unit`,
|
144
|
+
* but this is not necessary.
|
145
|
+
*
|
146
|
+
* @usecase def foreach(f: A => Unit): Unit
|
147
|
+
*/
|
148
|
+
def foreach[U](f: A => U): Unit
|
149
|
+
|
150
|
+
/** Tests whether this $coll is empty.
|
151
|
+
*
|
152
|
+
* @return `true` if the $coll contain no elements, `false` otherwise.
|
153
|
+
*/
|
154
|
+
def isEmpty: Boolean = {
|
155
|
+
var result = true
|
156
|
+
breakable {
|
157
|
+
for (x <- this) {
|
158
|
+
result = false
|
159
|
+
break
|
160
|
+
}
|
161
|
+
}
|
162
|
+
result
|
163
|
+
}
|
164
|
+
|
165
|
+
/** Tests whether this $coll is known to have a finite size.
|
166
|
+
* All strict collections are known to have finite size. For a non-strict collection
|
167
|
+
* such as `Stream`, the predicate returns `true` if all elements have been computed.
|
168
|
+
* It returns `false` if the stream is not yet evaluated to the end.
|
169
|
+
*
|
170
|
+
* Note: many collection methods will not work on collections of infinite sizes.
|
171
|
+
*
|
172
|
+
* @return `true` if this collection is known to have finite size, `false` otherwise.
|
173
|
+
*/
|
174
|
+
def hasDefiniteSize = true
|
175
|
+
|
176
|
+
def ++[B >: A, That](that: GenTraversableOnce[B])(implicit bf: CanBuildFrom[Repr, B, That]): That = {
|
177
|
+
val b = bf(repr)
|
178
|
+
if (that.isInstanceOf[IndexedSeqLike[_, _]]) b.sizeHint(this, that.seq.size)
|
179
|
+
b ++= thisCollection
|
180
|
+
b ++= that.seq
|
181
|
+
b.result
|
182
|
+
}
|
183
|
+
|
184
|
+
@bridge
|
185
|
+
def ++[B >: A, That](that: TraversableOnce[B])(implicit bf: CanBuildFrom[Repr, B, That]): That =
|
186
|
+
++(that: GenTraversableOnce[B])(bf)
|
187
|
+
|
188
|
+
/** Concatenates this $coll with the elements of a traversable collection.
|
189
|
+
* It differs from ++ in that the right operand determines the type of the
|
190
|
+
* resulting collection rather than the left one.
|
191
|
+
*
|
192
|
+
* @param that the traversable to append.
|
193
|
+
* @tparam B the element type of the returned collection.
|
194
|
+
* @tparam That $thatinfo
|
195
|
+
* @param bf $bfinfo
|
196
|
+
* @return a new collection of type `That` which contains all elements
|
197
|
+
* of this $coll followed by all elements of `that`.
|
198
|
+
*
|
199
|
+
* @usecase def ++:[B](that: TraversableOnce[B]): $Coll[B]
|
200
|
+
*
|
201
|
+
* @return a new $coll which contains all elements of this $coll
|
202
|
+
* followed by all elements of `that`.
|
203
|
+
*/
|
204
|
+
def ++:[B >: A, That](that: TraversableOnce[B])(implicit bf: CanBuildFrom[Repr, B, That]): That = {
|
205
|
+
val b = bf(repr)
|
206
|
+
if (that.isInstanceOf[IndexedSeqLike[_, _]]) b.sizeHint(this, that.size)
|
207
|
+
b ++= that
|
208
|
+
b ++= thisCollection
|
209
|
+
b.result
|
210
|
+
}
|
211
|
+
|
212
|
+
/** This overload exists because: for the implementation of ++: we should reuse
|
213
|
+
* that of ++ because many collections override it with more efficient versions.
|
214
|
+
* Since TraversableOnce has no '++' method, we have to implement that directly,
|
215
|
+
* but Traversable and down can use the overload.
|
216
|
+
*/
|
217
|
+
def ++:[B >: A, That](that: Traversable[B])(implicit bf: CanBuildFrom[Repr, B, That]): That =
|
218
|
+
(that ++ seq)(breakOut)
|
219
|
+
|
220
|
+
def map[B, That](f: A => B)(implicit bf: CanBuildFrom[Repr, B, That]): That = {
|
221
|
+
val b = bf(repr)
|
222
|
+
b.sizeHint(this)
|
223
|
+
for (x <- this) b += f(x)
|
224
|
+
b.result
|
225
|
+
}
|
226
|
+
|
227
|
+
def flatMap[B, That](f: A => GenTraversableOnce[B])(implicit bf: CanBuildFrom[Repr, B, That]): That = {
|
228
|
+
val b = bf(repr)
|
229
|
+
for (x <- this) b ++= f(x).seq
|
230
|
+
b.result
|
231
|
+
}
|
232
|
+
|
233
|
+
/** Selects all elements of this $coll which satisfy a predicate.
|
234
|
+
*
|
235
|
+
* @param p the predicate used to test elements.
|
236
|
+
* @return a new $coll consisting of all elements of this $coll that satisfy the given
|
237
|
+
* predicate `p`. The order of the elements is preserved.
|
238
|
+
*/
|
239
|
+
def filter(p: A => Boolean): Repr = {
|
240
|
+
val b = newBuilder
|
241
|
+
for (x <- this)
|
242
|
+
if (p(x)) b += x
|
243
|
+
b.result
|
244
|
+
}
|
245
|
+
|
246
|
+
/** Selects all elements of this $coll which do not satisfy a predicate.
|
247
|
+
*
|
248
|
+
* @param p the predicate used to test elements.
|
249
|
+
* @return a new $coll consisting of all elements of this $coll that do not satisfy the given
|
250
|
+
* predicate `p`. The order of the elements is preserved.
|
251
|
+
*/
|
252
|
+
def filterNot(p: A => Boolean): Repr = filter(!p(_))
|
253
|
+
|
254
|
+
def collect[B, That](pf: PartialFunction[A, B])(implicit bf: CanBuildFrom[Repr, B, That]): That = {
|
255
|
+
val b = bf(repr)
|
256
|
+
for (x <- this) if (pf.isDefinedAt(x)) b += pf(x)
|
257
|
+
b.result
|
258
|
+
}
|
259
|
+
|
260
|
+
/** Builds a new collection by applying an option-valued function to all
|
261
|
+
* elements of this $coll on which the function is defined.
|
262
|
+
*
|
263
|
+
* @param f the option-valued function which filters and maps the $coll.
|
264
|
+
* @tparam B the element type of the returned collection.
|
265
|
+
* @tparam That $thatinfo
|
266
|
+
* @param bf $bfinfo
|
267
|
+
* @return a new collection of type `That` resulting from applying the option-valued function
|
268
|
+
* `f` to each element and collecting all defined results.
|
269
|
+
* The order of the elements is preserved.
|
270
|
+
*
|
271
|
+
* @usecase def filterMap[B](f: A => Option[B]): $Coll[B]
|
272
|
+
*
|
273
|
+
* @param pf the partial function which filters and maps the $coll.
|
274
|
+
* @return a new $coll resulting from applying the given option-valued function
|
275
|
+
* `f` to each element and collecting all defined results.
|
276
|
+
* The order of the elements is preserved.
|
277
|
+
def filterMap[B, That](f: A => Option[B])(implicit bf: CanBuildFrom[Repr, B, That]): That = {
|
278
|
+
val b = bf(repr)
|
279
|
+
for (x <- this)
|
280
|
+
f(x) match {
|
281
|
+
case Some(y) => b += y
|
282
|
+
case _ =>
|
283
|
+
}
|
284
|
+
b.result
|
285
|
+
}
|
286
|
+
*/
|
287
|
+
|
288
|
+
/** Partitions this $coll in two ${coll}s according to a predicate.
|
289
|
+
*
|
290
|
+
* @param p the predicate on which to partition.
|
291
|
+
* @return a pair of ${coll}s: the first $coll consists of all elements that
|
292
|
+
* satisfy the predicate `p` and the second $coll consists of all elements
|
293
|
+
* that don't. The relative order of the elements in the resulting ${coll}s
|
294
|
+
* is the same as in the original $coll.
|
295
|
+
*/
|
296
|
+
def partition(p: A => Boolean): (Repr, Repr) = {
|
297
|
+
val l, r = newBuilder
|
298
|
+
for (x <- this) (if (p(x)) l else r) += x
|
299
|
+
(l.result, r.result)
|
300
|
+
}
|
301
|
+
|
302
|
+
def groupBy[K](f: A => K): immutable.Map[K, Repr] = {
|
303
|
+
val m = mutable.Map.empty[K, Builder[A, Repr]]
|
304
|
+
for (elem <- this) {
|
305
|
+
val key = f(elem)
|
306
|
+
val bldr = m.getOrElseUpdate(key, newBuilder)
|
307
|
+
bldr += elem
|
308
|
+
}
|
309
|
+
val b = immutable.Map.newBuilder[K, Repr]
|
310
|
+
for ((k, v) <- m)
|
311
|
+
b += ((k, v.result))
|
312
|
+
|
313
|
+
b.result
|
314
|
+
}
|
315
|
+
|
316
|
+
/** Tests whether a predicate holds for all elements of this $coll.
|
317
|
+
*
|
318
|
+
* $mayNotTerminateInf
|
319
|
+
*
|
320
|
+
* @param p the predicate used to test elements.
|
321
|
+
* @return `true` if the given predicate `p` holds for all elements
|
322
|
+
* of this $coll, otherwise `false`.
|
323
|
+
*/
|
324
|
+
def forall(p: A => Boolean): Boolean = {
|
325
|
+
var result = true
|
326
|
+
breakable {
|
327
|
+
for (x <- this)
|
328
|
+
if (!p(x)) { result = false; break }
|
329
|
+
}
|
330
|
+
result
|
331
|
+
}
|
332
|
+
|
333
|
+
/** Tests whether a predicate holds for some of the elements of this $coll.
|
334
|
+
*
|
335
|
+
* $mayNotTerminateInf
|
336
|
+
*
|
337
|
+
* @param p the predicate used to test elements.
|
338
|
+
* @return `true` if the given predicate `p` holds for some of the
|
339
|
+
* elements of this $coll, otherwise `false`.
|
340
|
+
*/
|
341
|
+
def exists(p: A => Boolean): Boolean = {
|
342
|
+
var result = false
|
343
|
+
breakable {
|
344
|
+
for (x <- this)
|
345
|
+
if (p(x)) { result = true; break }
|
346
|
+
}
|
347
|
+
result
|
348
|
+
}
|
349
|
+
|
350
|
+
/** Finds the first element of the $coll satisfying a predicate, if any.
|
351
|
+
*
|
352
|
+
* $mayNotTerminateInf
|
353
|
+
* $orderDependent
|
354
|
+
*
|
355
|
+
* @param p the predicate used to test elements.
|
356
|
+
* @return an option value containing the first element in the $coll
|
357
|
+
* that satisfies `p`, or `None` if none exists.
|
358
|
+
*/
|
359
|
+
def find(p: A => Boolean): Option[A] = {
|
360
|
+
var result: Option[A] = None
|
361
|
+
breakable {
|
362
|
+
for (x <- this)
|
363
|
+
if (p(x)) { result = Some(x); break }
|
364
|
+
}
|
365
|
+
result
|
366
|
+
}
|
367
|
+
|
368
|
+
def scan[B >: A, That](z: B)(op: (B, B) => B)(implicit cbf: CanBuildFrom[Repr, B, That]): That = scanLeft(z)(op)
|
369
|
+
|
370
|
+
def scanLeft[B, That](z: B)(op: (B, A) => B)(implicit bf: CanBuildFrom[Repr, B, That]): That = {
|
371
|
+
val b = bf(repr)
|
372
|
+
b.sizeHint(this, 1)
|
373
|
+
var acc = z
|
374
|
+
b += acc
|
375
|
+
for (x <- this) { acc = op(acc, x); b += acc }
|
376
|
+
b.result
|
377
|
+
}
|
378
|
+
|
379
|
+
@migration(2, 9,
|
380
|
+
"This scanRight definition has changed in 2.9.\n" +
|
381
|
+
"The previous behavior can be reproduced with scanRight.reverse."
|
382
|
+
)
|
383
|
+
def scanRight[B, That](z: B)(op: (A, B) => B)(implicit bf: CanBuildFrom[Repr, B, That]): That = {
|
384
|
+
var scanned = List(z)
|
385
|
+
var acc = z
|
386
|
+
for (x <- reversed) {
|
387
|
+
acc = op(x, acc)
|
388
|
+
scanned ::= acc
|
389
|
+
}
|
390
|
+
val b = bf(repr)
|
391
|
+
for (elem <- scanned) b += elem
|
392
|
+
b.result
|
393
|
+
}
|
394
|
+
|
395
|
+
/** Selects the first element of this $coll.
|
396
|
+
* $orderDependent
|
397
|
+
* @return the first element of this $coll.
|
398
|
+
* @throws `NoSuchElementException` if the $coll is empty.
|
399
|
+
*/
|
400
|
+
def head: A = {
|
401
|
+
var result: () => A = () => throw new NoSuchElementException
|
402
|
+
breakable {
|
403
|
+
for (x <- this) {
|
404
|
+
result = () => x
|
405
|
+
break
|
406
|
+
}
|
407
|
+
}
|
408
|
+
result()
|
409
|
+
}
|
410
|
+
|
411
|
+
/** Optionally selects the first element.
|
412
|
+
* $orderDependent
|
413
|
+
* @return the first element of this $coll if it is nonempty, `None` if it is empty.
|
414
|
+
*/
|
415
|
+
def headOption: Option[A] = if (isEmpty) None else Some(head)
|
416
|
+
|
417
|
+
/** Selects all elements except the first.
|
418
|
+
* $orderDependent
|
419
|
+
* @return a $coll consisting of all elements of this $coll
|
420
|
+
* except the first one.
|
421
|
+
* @throws `UnsupportedOperationException` if the $coll is empty.
|
422
|
+
*/
|
423
|
+
override def tail: Repr = {
|
424
|
+
if (isEmpty) throw new UnsupportedOperationException("empty.tail")
|
425
|
+
drop(1)
|
426
|
+
}
|
427
|
+
|
428
|
+
/** Selects the last element.
|
429
|
+
* $orderDependent
|
430
|
+
* @return The last element of this $coll.
|
431
|
+
* @throws NoSuchElementException If the $coll is empty.
|
432
|
+
*/
|
433
|
+
def last: A = {
|
434
|
+
var lst = head
|
435
|
+
for (x <- this)
|
436
|
+
lst = x
|
437
|
+
lst
|
438
|
+
}
|
439
|
+
|
440
|
+
/** Optionally selects the last element.
|
441
|
+
* $orderDependent
|
442
|
+
* @return the last element of this $coll$ if it is nonempty, `None` if it is empty.
|
443
|
+
*/
|
444
|
+
def lastOption: Option[A] = if (isEmpty) None else Some(last)
|
445
|
+
|
446
|
+
/** Selects all elements except the last.
|
447
|
+
* $orderDependent
|
448
|
+
* @return a $coll consisting of all elements of this $coll
|
449
|
+
* except the last one.
|
450
|
+
* @throws `UnsupportedOperationException` if the $coll is empty.
|
451
|
+
*/
|
452
|
+
def init: Repr = {
|
453
|
+
if (isEmpty) throw new UnsupportedOperationException("empty.init")
|
454
|
+
var lst = head
|
455
|
+
var follow = false
|
456
|
+
val b = newBuilder
|
457
|
+
b.sizeHint(this, -1)
|
458
|
+
for (x <- this.seq) {
|
459
|
+
if (follow) b += lst
|
460
|
+
else follow = true
|
461
|
+
lst = x
|
462
|
+
}
|
463
|
+
b.result
|
464
|
+
}
|
465
|
+
|
466
|
+
def take(n: Int): Repr = slice(0, n)
|
467
|
+
|
468
|
+
def drop(n: Int): Repr =
|
469
|
+
if (n <= 0) {
|
470
|
+
val b = newBuilder
|
471
|
+
b.sizeHint(this)
|
472
|
+
b ++= thisCollection result
|
473
|
+
}
|
474
|
+
else sliceWithKnownDelta(n, Int.MaxValue, -n)
|
475
|
+
|
476
|
+
def slice(from: Int, until: Int): Repr = sliceWithKnownBound(math.max(from, 0), until)
|
477
|
+
|
478
|
+
// Precondition: from >= 0, until > 0, builder already configured for building.
|
479
|
+
private[this] def sliceInternal(from: Int, until: Int, b: Builder[A, Repr]): Repr = {
|
480
|
+
var i = 0
|
481
|
+
breakable {
|
482
|
+
for (x <- this.seq) {
|
483
|
+
if (i >= from) b += x
|
484
|
+
i += 1
|
485
|
+
if (i >= until) break
|
486
|
+
}
|
487
|
+
}
|
488
|
+
b.result
|
489
|
+
}
|
490
|
+
// Precondition: from >= 0
|
491
|
+
private[scala] def sliceWithKnownDelta(from: Int, until: Int, delta: Int): Repr = {
|
492
|
+
val b = newBuilder
|
493
|
+
if (until <= from) b.result
|
494
|
+
else {
|
495
|
+
b.sizeHint(this, delta)
|
496
|
+
sliceInternal(from, until, b)
|
497
|
+
}
|
498
|
+
}
|
499
|
+
// Precondition: from >= 0
|
500
|
+
private[scala] def sliceWithKnownBound(from: Int, until: Int): Repr = {
|
501
|
+
val b = newBuilder
|
502
|
+
if (until <= from) b.result
|
503
|
+
else {
|
504
|
+
b.sizeHintBounded(until - from, this)
|
505
|
+
sliceInternal(from, until, b)
|
506
|
+
}
|
507
|
+
}
|
508
|
+
|
509
|
+
def takeWhile(p: A => Boolean): Repr = {
|
510
|
+
val b = newBuilder
|
511
|
+
breakable {
|
512
|
+
for (x <- this) {
|
513
|
+
if (!p(x)) break
|
514
|
+
b += x
|
515
|
+
}
|
516
|
+
}
|
517
|
+
b.result
|
518
|
+
}
|
519
|
+
|
520
|
+
def dropWhile(p: A => Boolean): Repr = {
|
521
|
+
val b = newBuilder
|
522
|
+
var go = false
|
523
|
+
for (x <- this) {
|
524
|
+
if (!p(x)) go = true
|
525
|
+
if (go) b += x
|
526
|
+
}
|
527
|
+
b.result
|
528
|
+
}
|
529
|
+
|
530
|
+
def span(p: A => Boolean): (Repr, Repr) = {
|
531
|
+
val l, r = newBuilder
|
532
|
+
var toLeft = true
|
533
|
+
for (x <- this) {
|
534
|
+
toLeft = toLeft && p(x)
|
535
|
+
(if (toLeft) l else r) += x
|
536
|
+
}
|
537
|
+
(l.result, r.result)
|
538
|
+
}
|
539
|
+
|
540
|
+
def splitAt(n: Int): (Repr, Repr) = {
|
541
|
+
val l, r = newBuilder
|
542
|
+
l.sizeHintBounded(n, this)
|
543
|
+
if (n >= 0) r.sizeHint(this, -n)
|
544
|
+
var i = 0
|
545
|
+
for (x <- this) {
|
546
|
+
(if (i < n) l else r) += x
|
547
|
+
i += 1
|
548
|
+
}
|
549
|
+
(l.result, r.result)
|
550
|
+
}
|
551
|
+
|
552
|
+
/** Iterates over the tails of this $coll. The first value will be this
|
553
|
+
* $coll and the final one will be an empty $coll, with the intervening
|
554
|
+
* values the results of successive applications of `tail`.
|
555
|
+
*
|
556
|
+
* @return an iterator over all the tails of this $coll
|
557
|
+
* @example `List(1,2,3).tails = Iterator(List(1,2,3), List(2,3), List(3), Nil)`
|
558
|
+
*/
|
559
|
+
def tails: Iterator[Repr] = iterateUntilEmpty(_.tail)
|
560
|
+
|
561
|
+
/** Iterates over the inits of this $coll. The first value will be this
|
562
|
+
* $coll and the final one will be an empty $coll, with the intervening
|
563
|
+
* values the results of successive applications of `init`.
|
564
|
+
*
|
565
|
+
* @return an iterator over all the inits of this $coll
|
566
|
+
* @example `List(1,2,3).inits = Iterator(List(1,2,3), List(1,2), List(1), Nil)`
|
567
|
+
*/
|
568
|
+
def inits: Iterator[Repr] = iterateUntilEmpty(_.init)
|
569
|
+
|
570
|
+
/** Copies elements of this $coll to an array.
|
571
|
+
* Fills the given array `xs` with at most `len` elements of
|
572
|
+
* this $coll, starting at position `start`.
|
573
|
+
* Copying will stop once either the end of the current $coll is reached,
|
574
|
+
* or the end of the array is reached, or `len` elements have been copied.
|
575
|
+
*
|
576
|
+
* $willNotTerminateInf
|
577
|
+
*
|
578
|
+
* @param xs the array to fill.
|
579
|
+
* @param start the starting index.
|
580
|
+
* @param len the maximal number of elements to copy.
|
581
|
+
* @tparam B the type of the elements of the array.
|
582
|
+
*
|
583
|
+
*
|
584
|
+
* @usecase def copyToArray(xs: Array[A], start: Int, len: Int): Unit
|
585
|
+
*/
|
586
|
+
def copyToArray[B >: A](xs: Array[B], start: Int, len: Int) {
|
587
|
+
var i = start
|
588
|
+
val end = (start + len) min xs.length
|
589
|
+
breakable {
|
590
|
+
for (x <- this) {
|
591
|
+
if (i >= end) break
|
592
|
+
xs(i) = x
|
593
|
+
i += 1
|
594
|
+
}
|
595
|
+
}
|
596
|
+
}
|
597
|
+
|
598
|
+
def toTraversable: Traversable[A] = thisCollection
|
599
|
+
def toIterator: Iterator[A] = toStream.iterator
|
600
|
+
def toStream: Stream[A] = toBuffer.toStream
|
601
|
+
|
602
|
+
/** Converts this $coll to a string.
|
603
|
+
*
|
604
|
+
* @return a string representation of this collection. By default this
|
605
|
+
* string consists of the `stringPrefix` of this $coll,
|
606
|
+
* followed by all elements separated by commas and enclosed in parentheses.
|
607
|
+
*/
|
608
|
+
override def toString = mkString(stringPrefix + "(", ", ", ")")
|
609
|
+
|
610
|
+
/** Defines the prefix of this object's `toString` representation.
|
611
|
+
*
|
612
|
+
* @return a string representation which starts the result of `toString`
|
613
|
+
* applied to this $coll. By default the string prefix is the
|
614
|
+
* simple name of the collection class $coll.
|
615
|
+
*/
|
616
|
+
def stringPrefix : String = {
|
617
|
+
var string = repr.asInstanceOf[AnyRef].getClass.getName
|
618
|
+
val idx1 = string.lastIndexOf('.' : Int)
|
619
|
+
if (idx1 != -1) string = string.substring(idx1 + 1)
|
620
|
+
val idx2 = string.indexOf('$')
|
621
|
+
if (idx2 != -1) string = string.substring(0, idx2)
|
622
|
+
string
|
623
|
+
}
|
624
|
+
|
625
|
+
/** Creates a non-strict view of this $coll.
|
626
|
+
*
|
627
|
+
* @return a non-strict view of this $coll.
|
628
|
+
*/
|
629
|
+
def view = new TraversableView[A, Repr] {
|
630
|
+
protected lazy val underlying = self.repr
|
631
|
+
override def foreach[U](f: A => U) = self foreach f
|
632
|
+
}
|
633
|
+
|
634
|
+
/** Creates a non-strict view of a slice of this $coll.
|
635
|
+
*
|
636
|
+
* Note: the difference between `view` and `slice` is that `view` produces
|
637
|
+
* a view of the current $coll, whereas `slice` produces a new $coll.
|
638
|
+
*
|
639
|
+
* Note: `view(from, to)` is equivalent to `view.slice(from, to)`
|
640
|
+
* $orderDependent
|
641
|
+
*
|
642
|
+
* @param from the index of the first element of the view
|
643
|
+
* @param until the index of the element following the view
|
644
|
+
* @return a non-strict view of a slice of this $coll, starting at index `from`
|
645
|
+
* and extending up to (but not including) index `until`.
|
646
|
+
*/
|
647
|
+
def view(from: Int, until: Int): TraversableView[A, Repr] = view.slice(from, until)
|
648
|
+
|
649
|
+
/** Creates a non-strict filter of this $coll.
|
650
|
+
*
|
651
|
+
* Note: the difference between `c filter p` and `c withFilter p` is that
|
652
|
+
* the former creates a new collection, whereas the latter only
|
653
|
+
* restricts the domain of subsequent `map`, `flatMap`, `foreach`,
|
654
|
+
* and `withFilter` operations.
|
655
|
+
* $orderDependent
|
656
|
+
*
|
657
|
+
* @param p the predicate used to test elements.
|
658
|
+
* @return an object of class `WithFilter`, which supports
|
659
|
+
* `map`, `flatMap`, `foreach`, and `withFilter` operations.
|
660
|
+
* All these operations apply to those elements of this $coll which
|
661
|
+
* satisfy the predicate `p`.
|
662
|
+
*/
|
663
|
+
def withFilter(p: A => Boolean): FilterMonadic[A, Repr] = new WithFilter(p)
|
664
|
+
|
665
|
+
/** A class supporting filtered operations. Instances of this class are
|
666
|
+
* returned by method `withFilter`.
|
667
|
+
*/
|
668
|
+
class WithFilter(p: A => Boolean) extends FilterMonadic[A, Repr] {
|
669
|
+
|
670
|
+
/** Builds a new collection by applying a function to all elements of the
|
671
|
+
* outer $coll containing this `WithFilter` instance that satisfy predicate `p`.
|
672
|
+
*
|
673
|
+
* @param f the function to apply to each element.
|
674
|
+
* @tparam B the element type of the returned collection.
|
675
|
+
* @tparam That $thatinfo
|
676
|
+
* @param bf $bfinfo
|
677
|
+
* @return a new collection of type `That` resulting from applying
|
678
|
+
* the given function `f` to each element of the outer $coll
|
679
|
+
* that satisfies predicate `p` and collecting the results.
|
680
|
+
*
|
681
|
+
* @usecase def map[B](f: A => B): $Coll[B]
|
682
|
+
*
|
683
|
+
* @return a new $coll resulting from applying the given function
|
684
|
+
* `f` to each element of the outer $coll that satisfies
|
685
|
+
* predicate `p` and collecting the results.
|
686
|
+
*/
|
687
|
+
def map[B, That](f: A => B)(implicit bf: CanBuildFrom[Repr, B, That]): That = {
|
688
|
+
val b = bf(repr)
|
689
|
+
for (x <- self)
|
690
|
+
if (p(x)) b += f(x)
|
691
|
+
b.result
|
692
|
+
}
|
693
|
+
|
694
|
+
/** Builds a new collection by applying a function to all elements of the
|
695
|
+
* outer $coll containing this `WithFilter` instance that satisfy
|
696
|
+
* predicate `p` and concatenating the results.
|
697
|
+
*
|
698
|
+
* @param f the function to apply to each element.
|
699
|
+
* @tparam B the element type of the returned collection.
|
700
|
+
* @tparam That $thatinfo
|
701
|
+
* @param bf $bfinfo
|
702
|
+
* @return a new collection of type `That` resulting from applying
|
703
|
+
* the given collection-valued function `f` to each element
|
704
|
+
* of the outer $coll that satisfies predicate `p` and
|
705
|
+
* concatenating the results.
|
706
|
+
*
|
707
|
+
* @usecase def flatMap[B](f: A => TraversableOnce[B]): $Coll[B]
|
708
|
+
*
|
709
|
+
* @return a new $coll resulting from applying the given collection-valued function
|
710
|
+
* `f` to each element of the outer $coll that satisfies predicate `p` and concatenating the results.
|
711
|
+
*/
|
712
|
+
def flatMap[B, That](f: A => GenTraversableOnce[B])(implicit bf: CanBuildFrom[Repr, B, That]): That = {
|
713
|
+
val b = bf(repr)
|
714
|
+
for (x <- self)
|
715
|
+
if (p(x)) b ++= f(x).seq
|
716
|
+
b.result
|
717
|
+
}
|
718
|
+
|
719
|
+
/** Applies a function `f` to all elements of the outer $coll containing
|
720
|
+
* this `WithFilter` instance that satisfy predicate `p`.
|
721
|
+
*
|
722
|
+
* @param f the function that is applied for its side-effect to every element.
|
723
|
+
* The result of function `f` is discarded.
|
724
|
+
*
|
725
|
+
* @tparam U the type parameter describing the result of function `f`.
|
726
|
+
* This result will always be ignored. Typically `U` is `Unit`,
|
727
|
+
* but this is not necessary.
|
728
|
+
*
|
729
|
+
* @usecase def foreach(f: A => Unit): Unit
|
730
|
+
*/
|
731
|
+
def foreach[U](f: A => U): Unit =
|
732
|
+
for (x <- self)
|
733
|
+
if (p(x)) f(x)
|
734
|
+
|
735
|
+
/** Further refines the filter for this $coll.
|
736
|
+
*
|
737
|
+
* @param q the predicate used to test elements.
|
738
|
+
* @return an object of class `WithFilter`, which supports
|
739
|
+
* `map`, `flatMap`, `foreach`, and `withFilter` operations.
|
740
|
+
* All these operations apply to those elements of this $coll which
|
741
|
+
* satisfy the predicate `q` in addition to the predicate `p`.
|
742
|
+
*/
|
743
|
+
def withFilter(q: A => Boolean): WithFilter =
|
744
|
+
new WithFilter(x => p(x) && q(x))
|
745
|
+
}
|
746
|
+
|
747
|
+
// A helper for tails and inits.
|
748
|
+
private def iterateUntilEmpty(f: Traversable[A @uV] => Traversable[A @uV]): Iterator[Repr] = {
|
749
|
+
val it = Iterator.iterate(thisCollection)(f) takeWhile (x => !x.isEmpty)
|
750
|
+
it ++ Iterator(Nil) map (newBuilder ++= _ result)
|
751
|
+
}
|
752
|
+
}
|
753
|
+
|
754
|
+
|
755
|
+
</textarea>
|
756
|
+
</form>
|
757
|
+
|
758
|
+
<script>
|
759
|
+
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
760
|
+
lineNumbers: true,
|
761
|
+
matchBrackets: true,
|
762
|
+
theme: "ambiance",
|
763
|
+
mode: "text/x-scala"
|
764
|
+
});
|
765
|
+
</script>
|
766
|
+
</body>
|
767
|
+
</html>
|