diff --git a/addon/hint/python-hint.js b/addon/hint/python-hint.js deleted file mode 100644 index 1b97f6ab0a13054ccda6d7851407a81addcc1059..0000000000000000000000000000000000000000 --- a/addon/hint/python-hint.js +++ /dev/null @@ -1,102 +0,0 @@ -// CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE - -(function(mod) { - if (typeof exports == "object" && typeof module == "object") // CommonJS - mod(require("../../lib/codemirror")); - else if (typeof define == "function" && define.amd) // AMD - define(["../../lib/codemirror"], mod); - else // Plain browser env - mod(CodeMirror); -})(function(CodeMirror) { - "use strict"; - - function forEach(arr, f) { - for (var i = 0, e = arr.length; i < e; ++i) f(arr[i]); - } - - function arrayContains(arr, item) { - if (!Array.prototype.indexOf) { - var i = arr.length; - while (i--) { - if (arr[i] === item) { - return true; - } - } - return false; - } - return arr.indexOf(item) != -1; - } - - function scriptHint(editor, _keywords, getToken) { - // Find the token at the cursor - var cur = editor.getCursor(), token = getToken(editor, cur), tprop = token; - // If it's not a 'word-style' token, ignore the token. - - if (!/^[\w$_]*$/.test(token.string)) { - token = tprop = {start: cur.ch, end: cur.ch, string: "", state: token.state, - className: token.string == ":" ? "python-type" : null}; - } - - if (!context) var context = []; - context.push(tprop); - - var completionList = getCompletions(token, context); - completionList = completionList.sort(); - - return {list: completionList, - from: CodeMirror.Pos(cur.line, token.start), - to: CodeMirror.Pos(cur.line, token.end)}; - } - - function pythonHint(editor) { - return scriptHint(editor, pythonKeywordsU, function (e, cur) {return e.getTokenAt(cur);}); - } - CodeMirror.registerHelper("hint", "python", pythonHint); - - var pythonKeywords = "and del from not while as elif global or with assert else if pass yield" -+ "break except import print class exec in raise continue finally is return def for lambda try"; - var pythonKeywordsL = pythonKeywords.split(" "); - var pythonKeywordsU = pythonKeywords.toUpperCase().split(" "); - - var pythonBuiltins = "abs divmod input open staticmethod all enumerate int ord str " -+ "any eval isinstance pow sum basestring execfile issubclass print super" -+ "bin file iter property tuple bool filter len range type" -+ "bytearray float list raw_input unichr callable format locals reduce unicode" -+ "chr frozenset long reload vars classmethod getattr map repr xrange" -+ "cmp globals max reversed zip compile hasattr memoryview round __import__" -+ "complex hash min set apply delattr help next setattr buffer" -+ "dict hex object slice coerce dir id oct sorted intern "; - var pythonBuiltinsL = pythonBuiltins.split(" ").join("() ").split(" "); - var pythonBuiltinsU = pythonBuiltins.toUpperCase().split(" ").join("() ").split(" "); - - function getCompletions(token, context) { - var found = [], start = token.string; - function maybeAdd(str) { - if (str.lastIndexOf(start, 0) == 0 && !arrayContains(found, str)) found.push(str); - } - - function gatherCompletions(_obj) { - forEach(pythonBuiltinsL, maybeAdd); - forEach(pythonBuiltinsU, maybeAdd); - forEach(pythonKeywordsL, maybeAdd); - forEach(pythonKeywordsU, maybeAdd); - } - - if (context) { - // If this is a property, see if it belongs to some object we can - // find in the current environment. - var obj = context.pop(), base; - - if (obj.type == "variable") - base = obj.string; - else if(obj.type == "variable-3") - base = ":" + obj.string; - - while (base != null && context.length) - base = base[context.pop().string]; - if (base != null) gatherCompletions(base); - } - return found; - } -}); diff --git a/doc/compress.html b/doc/compress.html index 3e047ca8f541e408461cb87100ef69adf11b3606..c729cc6ed878f4ab7926ed63d6456c3a1544fe90 100644 --- a/doc/compress.html +++ b/doc/compress.html @@ -217,7 +217,6 @@ <option value="http://codemirror.net/addon/mode/multiplex.js">multiplex.js</option> <option value="http://codemirror.net/addon/mode/overlay.js">overlay.js</option> <option value="http://codemirror.net/addon/display/placeholder.js">placeholder.js</option> - <option value="http://codemirror.net/addon/hint/python-hint.js">python-hint.js</option> <option value="http://codemirror.net/addon/display/rulers.js">rulers.js</option> <option value="http://codemirror.net/addon/runmode/runmode.js">runmode.js</option> <option value="http://codemirror.net/addon/runmode/runmode.node.js">runmode.node.js</option> diff --git a/doc/manual.html b/doc/manual.html index c08c52b9b2b90f8ecd3c12f7504a9064b6fdcc13..8cee223d6854ca2f171c5ec6a16ab56c12fcb7fa 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -2566,10 +2566,6 @@ editor.setOption("extraKeys", { <dd>A hinting function for CSS, SCSS, or LESS code. Defines <code>CodeMirror.hint.css</code>.</dd> - <dt id="addon_python-hint"><a href="../addon/hint/python-hint.js"><code>hint/python-hint.js</code></a></dt> - <dd>A very simple hinting function for Python code. - Defines <code>CodeMirror.hint.python</code>.</dd> - <dt id="addon_anyword-hint"><a href="../addon/hint/anyword-hint.js"><code>hint/anyword-hint.js</code></a></dt> <dd>A very simple hinting function (<code>CodeMirror.hint.anyword</code>) that simply looks for