fluentd-ui 0.3.12 → 0.3.13
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of fluentd-ui might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/ChangeLog +4 -0
- data/Gemfile.lock +1 -1
- data/app/assets/javascripts/application.js +2 -0
- data/app/assets/javascripts/codemirror.js +29 -0
- data/app/assets/javascripts/codemirror_fluentd.js +59 -0
- data/app/assets/stylesheets/application.css +6 -0
- data/app/views/fluentd/settings/edit.html.haml +1 -1
- data/app/views/shared/vue/_setting.html.erb +1 -1
- data/bower.json +2 -1
- data/lib/fluentd-ui/version.rb +1 -1
- data/spec/features/source_and_output_spec.rb +16 -6
- data/vendor/assets/javascripts/bower/codemirror/.bower.json +29 -0
- data/vendor/assets/javascripts/bower/codemirror/AUTHORS +423 -0
- data/vendor/assets/javascripts/bower/codemirror/CONTRIBUTING.md +76 -0
- data/vendor/assets/javascripts/bower/codemirror/LICENSE +19 -0
- data/vendor/assets/javascripts/bower/codemirror/README.md +11 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/comment/comment.js +183 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/comment/continuecomment.js +85 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/dialog/dialog.css +32 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/dialog/dialog.js +155 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/display/fullscreen.css +6 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/display/fullscreen.js +41 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/display/panel.js +94 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/display/placeholder.js +58 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/display/rulers.js +64 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/edit/closebrackets.js +159 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/edit/closetag.js +159 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/edit/continuelist.js +51 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/edit/matchbrackets.js +120 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/edit/matchtags.js +66 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/edit/trailingspace.js +27 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/fold/brace-fold.js +105 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/fold/comment-fold.js +57 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/fold/foldcode.js +145 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/fold/foldgutter.css +20 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/fold/foldgutter.js +134 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/fold/indent-fold.js +44 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/fold/markdown-fold.js +49 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/fold/xml-fold.js +182 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/hint/anyword-hint.js +41 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/hint/css-hint.js +56 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/hint/html-hint.js +348 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/hint/javascript-hint.js +146 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/hint/show-hint.css +38 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/hint/show-hint.js +389 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/hint/sql-hint.js +197 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/hint/xml-hint.js +110 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/lint/coffeescript-lint.js +41 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/lint/css-lint.js +35 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/lint/javascript-lint.js +136 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/lint/json-lint.js +31 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/lint/lint.css +73 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/lint/lint.js +204 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/lint/yaml-lint.js +28 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/merge/merge.css +112 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/merge/merge.js +643 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/mode/loadmode.js +64 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/mode/multiplex.js +118 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/mode/multiplex_test.js +33 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/mode/overlay.js +85 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/mode/simple.js +213 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/runmode/colorize.js +40 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/runmode/runmode-standalone.js +157 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/runmode/runmode.js +72 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/runmode/runmode.node.js +120 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/scroll/annotatescrollbar.js +76 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/scroll/scrollpastend.js +46 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/scroll/simplescrollbars.css +66 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/scroll/simplescrollbars.js +139 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/search/match-highlighter.js +128 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/search/matchesonscrollbar.css +8 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/search/matchesonscrollbar.js +90 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/search/search.js +164 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/search/searchcursor.js +189 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/selection/active-line.js +71 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/selection/mark-selection.js +118 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/tern/tern.css +86 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/tern/tern.js +670 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/tern/worker.js +44 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/wrap/hardwrap.js +139 -0
- data/vendor/assets/javascripts/bower/codemirror/bower.json +16 -0
- data/vendor/assets/javascripts/bower/codemirror/keymap/emacs.js +411 -0
- data/vendor/assets/javascripts/bower/codemirror/keymap/sublime.js +540 -0
- data/vendor/assets/javascripts/bower/codemirror/keymap/vim.js +4901 -0
- data/vendor/assets/javascripts/bower/codemirror/lib/codemirror.css +309 -0
- data/vendor/assets/javascripts/bower/codemirror/lib/codemirror.js +8029 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/apl/apl.js +175 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/asterisk/asterisk.js +198 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/clike/clike.js +489 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/clike/scala.html +767 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/clojure/clojure.js +243 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/cobol/cobol.js +255 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/coffeescript/coffeescript.js +369 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/commonlisp/commonlisp.js +122 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/css/css.js +717 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/css/less.html +152 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/css/less_test.js +51 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/css/scss.html +157 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/css/scss_test.js +110 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/css/test.js +135 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/cypher/cypher.js +146 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/d/d.js +218 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/dart/dart.js +50 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/diff/diff.js +47 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/django/django.js +67 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/dockerfile/dockerfile.js +76 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/dtd/dtd.js +142 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/dylan/dylan.js +299 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/ebnf/ebnf.js +195 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/ecl/ecl.js +207 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/eiffel/eiffel.js +162 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/erlang/erlang.js +622 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/fortran/fortran.js +188 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/gas/gas.js +345 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/gfm/gfm.js +123 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/gfm/test.js +213 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/gherkin/gherkin.js +178 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/go/go.js +184 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/groovy/groovy.js +226 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/haml/haml.js +159 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/haml/test.js +97 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/haskell/haskell.js +267 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/haxe/haxe.js +518 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/htmlembedded/htmlembedded.js +86 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/htmlmixed/htmlmixed.js +121 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/http/http.js +113 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/idl/idl.js +290 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/jade/jade.js +590 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/javascript/javascript.js +686 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/javascript/json-ld.html +72 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/javascript/test.js +200 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/javascript/typescript.html +61 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/jinja2/jinja2.js +142 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/julia/julia.js +301 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/kotlin/kotlin.js +280 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/livescript/livescript.js +280 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/lua/lua.js +159 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/markdown/markdown.js +765 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/markdown/test.js +754 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/meta.js +165 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/mirc/mirc.js +193 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/mllike/mllike.js +205 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/modelica/modelica.js +245 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/nginx/nginx.js +178 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/ntriples/ntriples.js +186 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/octave/octave.js +135 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/pascal/pascal.js +109 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/pegjs/pegjs.js +114 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/perl/perl.js +832 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/php/php.js +226 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/php/test.js +154 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/pig/pig.js +188 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/properties/properties.js +78 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/puppet/puppet.js +220 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/python/python.js +359 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/q/q.js +139 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/r/r.js +162 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/rpm/rpm.js +101 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/rst/rst.js +557 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/ruby/ruby.js +285 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/ruby/test.js +14 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/rust/rust.js +451 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/sass/sass.js +327 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/scheme/scheme.js +248 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/shell/shell.js +139 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/shell/test.js +58 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/sieve/sieve.js +193 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/slim/slim.js +575 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/slim/test.js +96 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/smalltalk/smalltalk.js +168 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/smarty/smarty.js +221 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/smartymixed/smartymixed.js +197 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/solr/solr.js +104 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/soy/soy.js +198 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/sparql/sparql.js +174 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/spreadsheet/spreadsheet.js +109 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/sql/sql.js +391 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/stex/stex.js +251 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/stex/test.js +123 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/tcl/tcl.js +147 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/textile/test.js +417 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/textile/textile.js +469 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/tiddlywiki/tiddlywiki.css +14 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/tiddlywiki/tiddlywiki.js +369 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/tiki/tiki.css +26 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/tiki/tiki.js +323 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/toml/toml.js +88 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/tornado/tornado.js +68 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/turtle/turtle.js +162 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/vb/vb.js +274 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/vbscript/vbscript.js +350 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/velocity/velocity.js +201 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/verilog/test.js +273 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/verilog/verilog.js +364 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/xml/test.js +51 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/xml/xml.js +384 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/xquery/test.js +67 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/xquery/xquery.js +447 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/yaml/yaml.js +117 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/z80/z80.js +100 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/3024-day.css +38 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/3024-night.css +37 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/ambiance-mobile.css +5 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/ambiance.css +77 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/base16-dark.css +36 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/base16-light.css +36 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/blackboard.css +30 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/cobalt.css +23 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/eclipse.css +23 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/elegant.css +13 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/erlang-dark.css +32 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/lesser-dark.css +45 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/mbo.css +35 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/mdn-like.css +44 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/midnight.css +45 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/monokai.css +31 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/neat.css +12 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/neo.css +43 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/night.css +26 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/paraiso-dark.css +36 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/paraiso-light.css +36 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/pastel-on-dark.css +50 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/rubyblue.css +23 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/solarized.css +165 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/the-matrix.css +28 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/tomorrow-night-bright.css +35 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/tomorrow-night-eighties.css +36 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/twilight.css +30 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/vibrant-ink.css +32 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/xq-dark.css +51 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/xq-light.css +43 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/zenburn.css +37 -0
- metadata +225 -2
@@ -0,0 +1,38 @@
|
|
1
|
+
.CodeMirror-hints {
|
2
|
+
position: absolute;
|
3
|
+
z-index: 10;
|
4
|
+
overflow: hidden;
|
5
|
+
list-style: none;
|
6
|
+
|
7
|
+
margin: 0;
|
8
|
+
padding: 2px;
|
9
|
+
|
10
|
+
-webkit-box-shadow: 2px 3px 5px rgba(0,0,0,.2);
|
11
|
+
-moz-box-shadow: 2px 3px 5px rgba(0,0,0,.2);
|
12
|
+
box-shadow: 2px 3px 5px rgba(0,0,0,.2);
|
13
|
+
border-radius: 3px;
|
14
|
+
border: 1px solid silver;
|
15
|
+
|
16
|
+
background: white;
|
17
|
+
font-size: 90%;
|
18
|
+
font-family: monospace;
|
19
|
+
|
20
|
+
max-height: 20em;
|
21
|
+
overflow-y: auto;
|
22
|
+
}
|
23
|
+
|
24
|
+
.CodeMirror-hint {
|
25
|
+
margin: 0;
|
26
|
+
padding: 0 4px;
|
27
|
+
border-radius: 2px;
|
28
|
+
max-width: 19em;
|
29
|
+
overflow: hidden;
|
30
|
+
white-space: pre;
|
31
|
+
color: black;
|
32
|
+
cursor: pointer;
|
33
|
+
}
|
34
|
+
|
35
|
+
li.CodeMirror-hint-active {
|
36
|
+
background: #08f;
|
37
|
+
color: white;
|
38
|
+
}
|
@@ -0,0 +1,389 @@
|
|
1
|
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2
|
+
// Distributed under an MIT license: http://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
|
+
var HINT_ELEMENT_CLASS = "CodeMirror-hint";
|
15
|
+
var ACTIVE_HINT_ELEMENT_CLASS = "CodeMirror-hint-active";
|
16
|
+
|
17
|
+
// This is the old interface, kept around for now to stay
|
18
|
+
// backwards-compatible.
|
19
|
+
CodeMirror.showHint = function(cm, getHints, options) {
|
20
|
+
if (!getHints) return cm.showHint(options);
|
21
|
+
if (options && options.async) getHints.async = true;
|
22
|
+
var newOpts = {hint: getHints};
|
23
|
+
if (options) for (var prop in options) newOpts[prop] = options[prop];
|
24
|
+
return cm.showHint(newOpts);
|
25
|
+
};
|
26
|
+
|
27
|
+
CodeMirror.defineExtension("showHint", function(options) {
|
28
|
+
// We want a single cursor position.
|
29
|
+
if (this.listSelections().length > 1 || this.somethingSelected()) return;
|
30
|
+
|
31
|
+
if (this.state.completionActive) this.state.completionActive.close();
|
32
|
+
var completion = this.state.completionActive = new Completion(this, options);
|
33
|
+
var getHints = completion.options.hint;
|
34
|
+
if (!getHints) return;
|
35
|
+
|
36
|
+
CodeMirror.signal(this, "startCompletion", this);
|
37
|
+
if (getHints.async)
|
38
|
+
getHints(this, function(hints) { completion.showHints(hints); }, completion.options);
|
39
|
+
else
|
40
|
+
return completion.showHints(getHints(this, completion.options));
|
41
|
+
});
|
42
|
+
|
43
|
+
function Completion(cm, options) {
|
44
|
+
this.cm = cm;
|
45
|
+
this.options = this.buildOptions(options);
|
46
|
+
this.widget = this.onClose = null;
|
47
|
+
}
|
48
|
+
|
49
|
+
Completion.prototype = {
|
50
|
+
close: function() {
|
51
|
+
if (!this.active()) return;
|
52
|
+
this.cm.state.completionActive = null;
|
53
|
+
|
54
|
+
if (this.widget) this.widget.close();
|
55
|
+
if (this.onClose) this.onClose();
|
56
|
+
CodeMirror.signal(this.cm, "endCompletion", this.cm);
|
57
|
+
},
|
58
|
+
|
59
|
+
active: function() {
|
60
|
+
return this.cm.state.completionActive == this;
|
61
|
+
},
|
62
|
+
|
63
|
+
pick: function(data, i) {
|
64
|
+
var completion = data.list[i];
|
65
|
+
if (completion.hint) completion.hint(this.cm, data, completion);
|
66
|
+
else this.cm.replaceRange(getText(completion), completion.from || data.from,
|
67
|
+
completion.to || data.to, "complete");
|
68
|
+
CodeMirror.signal(data, "pick", completion);
|
69
|
+
this.close();
|
70
|
+
},
|
71
|
+
|
72
|
+
showHints: function(data) {
|
73
|
+
if (!data || !data.list.length || !this.active()) return this.close();
|
74
|
+
|
75
|
+
if (this.options.completeSingle && data.list.length == 1)
|
76
|
+
this.pick(data, 0);
|
77
|
+
else
|
78
|
+
this.showWidget(data);
|
79
|
+
},
|
80
|
+
|
81
|
+
showWidget: function(data) {
|
82
|
+
this.widget = new Widget(this, data);
|
83
|
+
CodeMirror.signal(data, "shown");
|
84
|
+
|
85
|
+
var debounce = 0, completion = this, finished;
|
86
|
+
var closeOn = this.options.closeCharacters;
|
87
|
+
var startPos = this.cm.getCursor(), startLen = this.cm.getLine(startPos.line).length;
|
88
|
+
|
89
|
+
var requestAnimationFrame = window.requestAnimationFrame || function(fn) {
|
90
|
+
return setTimeout(fn, 1000/60);
|
91
|
+
};
|
92
|
+
var cancelAnimationFrame = window.cancelAnimationFrame || clearTimeout;
|
93
|
+
|
94
|
+
function done() {
|
95
|
+
if (finished) return;
|
96
|
+
finished = true;
|
97
|
+
completion.close();
|
98
|
+
completion.cm.off("cursorActivity", activity);
|
99
|
+
if (data) CodeMirror.signal(data, "close");
|
100
|
+
}
|
101
|
+
|
102
|
+
function update() {
|
103
|
+
if (finished) return;
|
104
|
+
CodeMirror.signal(data, "update");
|
105
|
+
var getHints = completion.options.hint;
|
106
|
+
if (getHints.async)
|
107
|
+
getHints(completion.cm, finishUpdate, completion.options);
|
108
|
+
else
|
109
|
+
finishUpdate(getHints(completion.cm, completion.options));
|
110
|
+
}
|
111
|
+
function finishUpdate(data_) {
|
112
|
+
data = data_;
|
113
|
+
if (finished) return;
|
114
|
+
if (!data || !data.list.length) return done();
|
115
|
+
if (completion.widget) completion.widget.close();
|
116
|
+
completion.widget = new Widget(completion, data);
|
117
|
+
}
|
118
|
+
|
119
|
+
function clearDebounce() {
|
120
|
+
if (debounce) {
|
121
|
+
cancelAnimationFrame(debounce);
|
122
|
+
debounce = 0;
|
123
|
+
}
|
124
|
+
}
|
125
|
+
|
126
|
+
function activity() {
|
127
|
+
clearDebounce();
|
128
|
+
var pos = completion.cm.getCursor(), line = completion.cm.getLine(pos.line);
|
129
|
+
if (pos.line != startPos.line || line.length - pos.ch != startLen - startPos.ch ||
|
130
|
+
pos.ch < startPos.ch || completion.cm.somethingSelected() ||
|
131
|
+
(pos.ch && closeOn.test(line.charAt(pos.ch - 1)))) {
|
132
|
+
completion.close();
|
133
|
+
} else {
|
134
|
+
debounce = requestAnimationFrame(update);
|
135
|
+
if (completion.widget) completion.widget.close();
|
136
|
+
}
|
137
|
+
}
|
138
|
+
this.cm.on("cursorActivity", activity);
|
139
|
+
this.onClose = done;
|
140
|
+
},
|
141
|
+
|
142
|
+
buildOptions: function(options) {
|
143
|
+
var editor = this.cm.options.hintOptions;
|
144
|
+
var out = {};
|
145
|
+
for (var prop in defaultOptions) out[prop] = defaultOptions[prop];
|
146
|
+
if (editor) for (var prop in editor)
|
147
|
+
if (editor[prop] !== undefined) out[prop] = editor[prop];
|
148
|
+
if (options) for (var prop in options)
|
149
|
+
if (options[prop] !== undefined) out[prop] = options[prop];
|
150
|
+
return out;
|
151
|
+
}
|
152
|
+
};
|
153
|
+
|
154
|
+
function getText(completion) {
|
155
|
+
if (typeof completion == "string") return completion;
|
156
|
+
else return completion.text;
|
157
|
+
}
|
158
|
+
|
159
|
+
function buildKeyMap(completion, handle) {
|
160
|
+
var baseMap = {
|
161
|
+
Up: function() {handle.moveFocus(-1);},
|
162
|
+
Down: function() {handle.moveFocus(1);},
|
163
|
+
PageUp: function() {handle.moveFocus(-handle.menuSize() + 1, true);},
|
164
|
+
PageDown: function() {handle.moveFocus(handle.menuSize() - 1, true);},
|
165
|
+
Home: function() {handle.setFocus(0);},
|
166
|
+
End: function() {handle.setFocus(handle.length - 1);},
|
167
|
+
Enter: handle.pick,
|
168
|
+
Tab: handle.pick,
|
169
|
+
Esc: handle.close
|
170
|
+
};
|
171
|
+
var custom = completion.options.customKeys;
|
172
|
+
var ourMap = custom ? {} : baseMap;
|
173
|
+
function addBinding(key, val) {
|
174
|
+
var bound;
|
175
|
+
if (typeof val != "string")
|
176
|
+
bound = function(cm) { return val(cm, handle); };
|
177
|
+
// This mechanism is deprecated
|
178
|
+
else if (baseMap.hasOwnProperty(val))
|
179
|
+
bound = baseMap[val];
|
180
|
+
else
|
181
|
+
bound = val;
|
182
|
+
ourMap[key] = bound;
|
183
|
+
}
|
184
|
+
if (custom)
|
185
|
+
for (var key in custom) if (custom.hasOwnProperty(key))
|
186
|
+
addBinding(key, custom[key]);
|
187
|
+
var extra = completion.options.extraKeys;
|
188
|
+
if (extra)
|
189
|
+
for (var key in extra) if (extra.hasOwnProperty(key))
|
190
|
+
addBinding(key, extra[key]);
|
191
|
+
return ourMap;
|
192
|
+
}
|
193
|
+
|
194
|
+
function getHintElement(hintsElement, el) {
|
195
|
+
while (el && el != hintsElement) {
|
196
|
+
if (el.nodeName.toUpperCase() === "LI" && el.parentNode == hintsElement) return el;
|
197
|
+
el = el.parentNode;
|
198
|
+
}
|
199
|
+
}
|
200
|
+
|
201
|
+
function Widget(completion, data) {
|
202
|
+
this.completion = completion;
|
203
|
+
this.data = data;
|
204
|
+
var widget = this, cm = completion.cm;
|
205
|
+
|
206
|
+
var hints = this.hints = document.createElement("ul");
|
207
|
+
hints.className = "CodeMirror-hints";
|
208
|
+
this.selectedHint = data.selectedHint || 0;
|
209
|
+
|
210
|
+
var completions = data.list;
|
211
|
+
for (var i = 0; i < completions.length; ++i) {
|
212
|
+
var elt = hints.appendChild(document.createElement("li")), cur = completions[i];
|
213
|
+
var className = HINT_ELEMENT_CLASS + (i != this.selectedHint ? "" : " " + ACTIVE_HINT_ELEMENT_CLASS);
|
214
|
+
if (cur.className != null) className = cur.className + " " + className;
|
215
|
+
elt.className = className;
|
216
|
+
if (cur.render) cur.render(elt, data, cur);
|
217
|
+
else elt.appendChild(document.createTextNode(cur.displayText || getText(cur)));
|
218
|
+
elt.hintId = i;
|
219
|
+
}
|
220
|
+
|
221
|
+
var pos = cm.cursorCoords(completion.options.alignWithWord ? data.from : null);
|
222
|
+
var left = pos.left, top = pos.bottom, below = true;
|
223
|
+
hints.style.left = left + "px";
|
224
|
+
hints.style.top = top + "px";
|
225
|
+
// If we're at the edge of the screen, then we want the menu to appear on the left of the cursor.
|
226
|
+
var winW = window.innerWidth || Math.max(document.body.offsetWidth, document.documentElement.offsetWidth);
|
227
|
+
var winH = window.innerHeight || Math.max(document.body.offsetHeight, document.documentElement.offsetHeight);
|
228
|
+
(completion.options.container || document.body).appendChild(hints);
|
229
|
+
var box = hints.getBoundingClientRect(), overlapY = box.bottom - winH;
|
230
|
+
if (overlapY > 0) {
|
231
|
+
var height = box.bottom - box.top, curTop = pos.top - (pos.bottom - box.top);
|
232
|
+
if (curTop - height > 0) { // Fits above cursor
|
233
|
+
hints.style.top = (top = pos.top - height) + "px";
|
234
|
+
below = false;
|
235
|
+
} else if (height > winH) {
|
236
|
+
hints.style.height = (winH - 5) + "px";
|
237
|
+
hints.style.top = (top = pos.bottom - box.top) + "px";
|
238
|
+
var cursor = cm.getCursor();
|
239
|
+
if (data.from.ch != cursor.ch) {
|
240
|
+
pos = cm.cursorCoords(cursor);
|
241
|
+
hints.style.left = (left = pos.left) + "px";
|
242
|
+
box = hints.getBoundingClientRect();
|
243
|
+
}
|
244
|
+
}
|
245
|
+
}
|
246
|
+
var overlapX = box.right - winW;
|
247
|
+
if (overlapX > 0) {
|
248
|
+
if (box.right - box.left > winW) {
|
249
|
+
hints.style.width = (winW - 5) + "px";
|
250
|
+
overlapX -= (box.right - box.left) - winW;
|
251
|
+
}
|
252
|
+
hints.style.left = (left = pos.left - overlapX) + "px";
|
253
|
+
}
|
254
|
+
|
255
|
+
cm.addKeyMap(this.keyMap = buildKeyMap(completion, {
|
256
|
+
moveFocus: function(n, avoidWrap) { widget.changeActive(widget.selectedHint + n, avoidWrap); },
|
257
|
+
setFocus: function(n) { widget.changeActive(n); },
|
258
|
+
menuSize: function() { return widget.screenAmount(); },
|
259
|
+
length: completions.length,
|
260
|
+
close: function() { completion.close(); },
|
261
|
+
pick: function() { widget.pick(); },
|
262
|
+
data: data
|
263
|
+
}));
|
264
|
+
|
265
|
+
if (completion.options.closeOnUnfocus) {
|
266
|
+
var closingOnBlur;
|
267
|
+
cm.on("blur", this.onBlur = function() { closingOnBlur = setTimeout(function() { completion.close(); }, 100); });
|
268
|
+
cm.on("focus", this.onFocus = function() { clearTimeout(closingOnBlur); });
|
269
|
+
}
|
270
|
+
|
271
|
+
var startScroll = cm.getScrollInfo();
|
272
|
+
cm.on("scroll", this.onScroll = function() {
|
273
|
+
var curScroll = cm.getScrollInfo(), editor = cm.getWrapperElement().getBoundingClientRect();
|
274
|
+
var newTop = top + startScroll.top - curScroll.top;
|
275
|
+
var point = newTop - (window.pageYOffset || (document.documentElement || document.body).scrollTop);
|
276
|
+
if (!below) point += hints.offsetHeight;
|
277
|
+
if (point <= editor.top || point >= editor.bottom) return completion.close();
|
278
|
+
hints.style.top = newTop + "px";
|
279
|
+
hints.style.left = (left + startScroll.left - curScroll.left) + "px";
|
280
|
+
});
|
281
|
+
|
282
|
+
CodeMirror.on(hints, "dblclick", function(e) {
|
283
|
+
var t = getHintElement(hints, e.target || e.srcElement);
|
284
|
+
if (t && t.hintId != null) {widget.changeActive(t.hintId); widget.pick();}
|
285
|
+
});
|
286
|
+
|
287
|
+
CodeMirror.on(hints, "click", function(e) {
|
288
|
+
var t = getHintElement(hints, e.target || e.srcElement);
|
289
|
+
if (t && t.hintId != null) {
|
290
|
+
widget.changeActive(t.hintId);
|
291
|
+
if (completion.options.completeOnSingleClick) widget.pick();
|
292
|
+
}
|
293
|
+
});
|
294
|
+
|
295
|
+
CodeMirror.on(hints, "mousedown", function() {
|
296
|
+
setTimeout(function(){cm.focus();}, 20);
|
297
|
+
});
|
298
|
+
|
299
|
+
CodeMirror.signal(data, "select", completions[0], hints.firstChild);
|
300
|
+
return true;
|
301
|
+
}
|
302
|
+
|
303
|
+
Widget.prototype = {
|
304
|
+
close: function() {
|
305
|
+
if (this.completion.widget != this) return;
|
306
|
+
this.completion.widget = null;
|
307
|
+
this.hints.parentNode.removeChild(this.hints);
|
308
|
+
this.completion.cm.removeKeyMap(this.keyMap);
|
309
|
+
|
310
|
+
var cm = this.completion.cm;
|
311
|
+
if (this.completion.options.closeOnUnfocus) {
|
312
|
+
cm.off("blur", this.onBlur);
|
313
|
+
cm.off("focus", this.onFocus);
|
314
|
+
}
|
315
|
+
cm.off("scroll", this.onScroll);
|
316
|
+
},
|
317
|
+
|
318
|
+
pick: function() {
|
319
|
+
this.completion.pick(this.data, this.selectedHint);
|
320
|
+
},
|
321
|
+
|
322
|
+
changeActive: function(i, avoidWrap) {
|
323
|
+
if (i >= this.data.list.length)
|
324
|
+
i = avoidWrap ? this.data.list.length - 1 : 0;
|
325
|
+
else if (i < 0)
|
326
|
+
i = avoidWrap ? 0 : this.data.list.length - 1;
|
327
|
+
if (this.selectedHint == i) return;
|
328
|
+
var node = this.hints.childNodes[this.selectedHint];
|
329
|
+
node.className = node.className.replace(" " + ACTIVE_HINT_ELEMENT_CLASS, "");
|
330
|
+
node = this.hints.childNodes[this.selectedHint = i];
|
331
|
+
node.className += " " + ACTIVE_HINT_ELEMENT_CLASS;
|
332
|
+
if (node.offsetTop < this.hints.scrollTop)
|
333
|
+
this.hints.scrollTop = node.offsetTop - 3;
|
334
|
+
else if (node.offsetTop + node.offsetHeight > this.hints.scrollTop + this.hints.clientHeight)
|
335
|
+
this.hints.scrollTop = node.offsetTop + node.offsetHeight - this.hints.clientHeight + 3;
|
336
|
+
CodeMirror.signal(this.data, "select", this.data.list[this.selectedHint], node);
|
337
|
+
},
|
338
|
+
|
339
|
+
screenAmount: function() {
|
340
|
+
return Math.floor(this.hints.clientHeight / this.hints.firstChild.offsetHeight) || 1;
|
341
|
+
}
|
342
|
+
};
|
343
|
+
|
344
|
+
CodeMirror.registerHelper("hint", "auto", function(cm, options) {
|
345
|
+
var helpers = cm.getHelpers(cm.getCursor(), "hint"), words;
|
346
|
+
if (helpers.length) {
|
347
|
+
for (var i = 0; i < helpers.length; i++) {
|
348
|
+
var cur = helpers[i](cm, options);
|
349
|
+
if (cur && cur.list.length) return cur;
|
350
|
+
}
|
351
|
+
} else if (words = cm.getHelper(cm.getCursor(), "hintWords")) {
|
352
|
+
if (words) return CodeMirror.hint.fromList(cm, {words: words});
|
353
|
+
} else if (CodeMirror.hint.anyword) {
|
354
|
+
return CodeMirror.hint.anyword(cm, options);
|
355
|
+
}
|
356
|
+
});
|
357
|
+
|
358
|
+
CodeMirror.registerHelper("hint", "fromList", function(cm, options) {
|
359
|
+
var cur = cm.getCursor(), token = cm.getTokenAt(cur);
|
360
|
+
var found = [];
|
361
|
+
for (var i = 0; i < options.words.length; i++) {
|
362
|
+
var word = options.words[i];
|
363
|
+
if (word.slice(0, token.string.length) == token.string)
|
364
|
+
found.push(word);
|
365
|
+
}
|
366
|
+
|
367
|
+
if (found.length) return {
|
368
|
+
list: found,
|
369
|
+
from: CodeMirror.Pos(cur.line, token.start),
|
370
|
+
to: CodeMirror.Pos(cur.line, token.end)
|
371
|
+
};
|
372
|
+
});
|
373
|
+
|
374
|
+
CodeMirror.commands.autocomplete = CodeMirror.showHint;
|
375
|
+
|
376
|
+
var defaultOptions = {
|
377
|
+
hint: CodeMirror.hint.auto,
|
378
|
+
completeSingle: true,
|
379
|
+
alignWithWord: true,
|
380
|
+
closeCharacters: /[\s()\[\]{};:>,]/,
|
381
|
+
closeOnUnfocus: true,
|
382
|
+
completeOnSingleClick: false,
|
383
|
+
container: null,
|
384
|
+
customKeys: null,
|
385
|
+
extraKeys: null
|
386
|
+
};
|
387
|
+
|
388
|
+
CodeMirror.defineOption("hintOptions", null);
|
389
|
+
});
|
@@ -0,0 +1,197 @@
|
|
1
|
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2
|
+
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3
|
+
|
4
|
+
(function(mod) {
|
5
|
+
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6
|
+
mod(require("../../lib/codemirror"), require("../../mode/sql/sql"));
|
7
|
+
else if (typeof define == "function" && define.amd) // AMD
|
8
|
+
define(["../../lib/codemirror", "../../mode/sql/sql"], mod);
|
9
|
+
else // Plain browser env
|
10
|
+
mod(CodeMirror);
|
11
|
+
})(function(CodeMirror) {
|
12
|
+
"use strict";
|
13
|
+
|
14
|
+
var tables;
|
15
|
+
var defaultTable;
|
16
|
+
var keywords;
|
17
|
+
var CONS = {
|
18
|
+
QUERY_DIV: ";",
|
19
|
+
ALIAS_KEYWORD: "AS"
|
20
|
+
};
|
21
|
+
var Pos = CodeMirror.Pos;
|
22
|
+
|
23
|
+
function getKeywords(editor) {
|
24
|
+
var mode = editor.doc.modeOption;
|
25
|
+
if (mode === "sql") mode = "text/x-sql";
|
26
|
+
return CodeMirror.resolveMode(mode).keywords;
|
27
|
+
}
|
28
|
+
|
29
|
+
function match(string, word) {
|
30
|
+
var len = string.length;
|
31
|
+
var sub = word.substr(0, len);
|
32
|
+
return string.toUpperCase() === sub.toUpperCase();
|
33
|
+
}
|
34
|
+
|
35
|
+
function addMatches(result, search, wordlist, formatter) {
|
36
|
+
for (var word in wordlist) {
|
37
|
+
if (!wordlist.hasOwnProperty(word)) continue;
|
38
|
+
if (Array.isArray(wordlist)) {
|
39
|
+
word = wordlist[word];
|
40
|
+
}
|
41
|
+
if (match(search, word)) {
|
42
|
+
result.push(formatter(word));
|
43
|
+
}
|
44
|
+
}
|
45
|
+
}
|
46
|
+
|
47
|
+
function nameCompletion(cur, token, result, editor) {
|
48
|
+
var useBacktick = (token.string.charAt(0) == "`");
|
49
|
+
var string = token.string.substr(1);
|
50
|
+
var prevToken = editor.getTokenAt(Pos(cur.line, token.start));
|
51
|
+
if (token.string.charAt(0) == "." || prevToken.string == "."){
|
52
|
+
//Suggest colunm names
|
53
|
+
if (prevToken.string == ".") {
|
54
|
+
var prevToken = editor.getTokenAt(Pos(cur.line, token.start - 1));
|
55
|
+
}
|
56
|
+
var table = prevToken.string;
|
57
|
+
//Check if backtick is used in table name. If yes, use it for columns too.
|
58
|
+
var useBacktickTable = false;
|
59
|
+
if (table.match(/`/g)) {
|
60
|
+
useBacktickTable = true;
|
61
|
+
table = table.replace(/`/g, "");
|
62
|
+
}
|
63
|
+
//Check if table is available. If not, find table by Alias
|
64
|
+
if (!tables.hasOwnProperty(table))
|
65
|
+
table = findTableByAlias(table, editor);
|
66
|
+
var columns = tables[table];
|
67
|
+
if (!columns) return;
|
68
|
+
|
69
|
+
if (useBacktick) {
|
70
|
+
addMatches(result, string, columns, function(w) {return "`" + w + "`";});
|
71
|
+
}
|
72
|
+
else if(useBacktickTable) {
|
73
|
+
addMatches(result, string, columns, function(w) {return ".`" + w + "`";});
|
74
|
+
}
|
75
|
+
else {
|
76
|
+
addMatches(result, string, columns, function(w) {return "." + w;});
|
77
|
+
}
|
78
|
+
}
|
79
|
+
else {
|
80
|
+
//Suggest table names or colums in defaultTable
|
81
|
+
while (token.start && string.charAt(0) == ".") {
|
82
|
+
token = editor.getTokenAt(Pos(cur.line, token.start - 1));
|
83
|
+
string = token.string + string;
|
84
|
+
}
|
85
|
+
if (useBacktick) {
|
86
|
+
addMatches(result, string, tables, function(w) {return "`" + w + "`";});
|
87
|
+
addMatches(result, string, defaultTable, function(w) {return "`" + w + "`";});
|
88
|
+
}
|
89
|
+
else {
|
90
|
+
addMatches(result, string, tables, function(w) {return w;});
|
91
|
+
addMatches(result, string, defaultTable, function(w) {return w;});
|
92
|
+
}
|
93
|
+
}
|
94
|
+
}
|
95
|
+
|
96
|
+
function eachWord(lineText, f) {
|
97
|
+
if (!lineText) return;
|
98
|
+
var excepted = /[,;]/g;
|
99
|
+
var words = lineText.split(" ");
|
100
|
+
for (var i = 0; i < words.length; i++) {
|
101
|
+
f(words[i]?words[i].replace(excepted, '') : '');
|
102
|
+
}
|
103
|
+
}
|
104
|
+
|
105
|
+
function convertCurToNumber(cur) {
|
106
|
+
// max characters of a line is 999,999.
|
107
|
+
return cur.line + cur.ch / Math.pow(10, 6);
|
108
|
+
}
|
109
|
+
|
110
|
+
function convertNumberToCur(num) {
|
111
|
+
return Pos(Math.floor(num), +num.toString().split('.').pop());
|
112
|
+
}
|
113
|
+
|
114
|
+
function findTableByAlias(alias, editor) {
|
115
|
+
var doc = editor.doc;
|
116
|
+
var fullQuery = doc.getValue();
|
117
|
+
var aliasUpperCase = alias.toUpperCase();
|
118
|
+
var previousWord = "";
|
119
|
+
var table = "";
|
120
|
+
var separator = [];
|
121
|
+
var validRange = {
|
122
|
+
start: Pos(0, 0),
|
123
|
+
end: Pos(editor.lastLine(), editor.getLineHandle(editor.lastLine()).length)
|
124
|
+
};
|
125
|
+
|
126
|
+
//add separator
|
127
|
+
var indexOfSeparator = fullQuery.indexOf(CONS.QUERY_DIV);
|
128
|
+
while(indexOfSeparator != -1) {
|
129
|
+
separator.push(doc.posFromIndex(indexOfSeparator));
|
130
|
+
indexOfSeparator = fullQuery.indexOf(CONS.QUERY_DIV, indexOfSeparator+1);
|
131
|
+
}
|
132
|
+
separator.unshift(Pos(0, 0));
|
133
|
+
separator.push(Pos(editor.lastLine(), editor.getLineHandle(editor.lastLine()).text.length));
|
134
|
+
|
135
|
+
//find valid range
|
136
|
+
var prevItem = 0;
|
137
|
+
var current = convertCurToNumber(editor.getCursor());
|
138
|
+
for (var i=0; i< separator.length; i++) {
|
139
|
+
var _v = convertCurToNumber(separator[i]);
|
140
|
+
if (current > prevItem && current <= _v) {
|
141
|
+
validRange = { start: convertNumberToCur(prevItem), end: convertNumberToCur(_v) };
|
142
|
+
break;
|
143
|
+
}
|
144
|
+
prevItem = _v;
|
145
|
+
}
|
146
|
+
|
147
|
+
var query = doc.getRange(validRange.start, validRange.end, false);
|
148
|
+
|
149
|
+
for (var i = 0; i < query.length; i++) {
|
150
|
+
var lineText = query[i];
|
151
|
+
eachWord(lineText, function(word) {
|
152
|
+
var wordUpperCase = word.toUpperCase();
|
153
|
+
if (wordUpperCase === aliasUpperCase && tables.hasOwnProperty(previousWord)) {
|
154
|
+
table = previousWord;
|
155
|
+
}
|
156
|
+
if (wordUpperCase !== CONS.ALIAS_KEYWORD) {
|
157
|
+
previousWord = word;
|
158
|
+
}
|
159
|
+
});
|
160
|
+
if (table) break;
|
161
|
+
}
|
162
|
+
return table;
|
163
|
+
}
|
164
|
+
|
165
|
+
CodeMirror.registerHelper("hint", "sql", function(editor, options) {
|
166
|
+
tables = (options && options.tables) || {};
|
167
|
+
var defaultTableName = options && options.defaultTable;
|
168
|
+
defaultTable = (defaultTableName && tables[defaultTableName] || []);
|
169
|
+
keywords = keywords || getKeywords(editor);
|
170
|
+
|
171
|
+
var cur = editor.getCursor();
|
172
|
+
var result = [];
|
173
|
+
var token = editor.getTokenAt(cur), start, end, search;
|
174
|
+
if (token.end > cur.ch) {
|
175
|
+
token.end = cur.ch;
|
176
|
+
token.string = token.string.slice(0, cur.ch - token.start);
|
177
|
+
}
|
178
|
+
|
179
|
+
if (token.string.match(/^[.`\w@]\w*$/)) {
|
180
|
+
search = token.string;
|
181
|
+
start = token.start;
|
182
|
+
end = token.end;
|
183
|
+
} else {
|
184
|
+
start = end = cur.ch;
|
185
|
+
search = "";
|
186
|
+
}
|
187
|
+
if (search.charAt(0) == "." || search.charAt(0) == "`") {
|
188
|
+
nameCompletion(cur, token, result, editor);
|
189
|
+
} else {
|
190
|
+
addMatches(result, search, tables, function(w) {return w;});
|
191
|
+
addMatches(result, search, defaultTable, function(w) {return w;});
|
192
|
+
addMatches(result, search, keywords, function(w) {return w.toUpperCase();});
|
193
|
+
}
|
194
|
+
|
195
|
+
return {list: result, from: Pos(cur.line, start), to: Pos(cur.line, end)};
|
196
|
+
});
|
197
|
+
});
|