tianta/_server/CodeMirror/tern.min.js

1 line
75 KiB
JavaScript
Raw Normal View History

2022-10-16 21:58:52 +08:00
!function(e,t){"object"==typeof exports&&"object"==typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e.tern||(e.tern={})).signal={})}(this,function(e){function t(e,t){var r=this._handlers||(this._handlers=Object.create(null));(r[e]||(r[e]=[])).push(t)}function r(e,t){var r=this._handlers&&this._handlers[e];if(r)for(var n=0;n<r.length;++n)if(r[n]==t){r.splice(n,1);break}}var n=[];function p(e,t){var r=e._handlers&&e._handlers[t];return r&&r.length?r.slice():n}function o(e,t,r,n,o){for(var i=p(this,e),s=0;s<i.length;++s)i[s].call(this,t,r,n,o)}function i(e,t,r,n,o){for(var i=p(this,e),s=0;s<i.length;++s){var a=i[s].call(this,t,r,n,o);if(a)return a}}function s(e){var t=this._handlers&&this._handlers[e];return t&&0<t.length&&t}e.mixin=function(e){return e.on=t,e.off=r,e.signal=o,e.signalReturnFirst=i,e.hasHandler=s,e}}),function(e,t){"object"==typeof exports&&"object"==typeof module?t(exports,require("./infer"),require("./signal"),require("acorn"),require("acorn-walk")):"function"==typeof define&&define.amd?define(["exports","./infer","./signal","acorn/dist/acorn","acorn-walk/dist/walk"],t):t(e.tern||(e.tern={}),tern,tern.signal,acorn,acorn.walk)}(this,function(e,T,t,O,P){"use strict";var o=Object.create(null);e.registerPlugin=function(e,t){o[e]=t};var n=e.defaultOptions={debug:!1,async:!1,getFile:function(e,t){this.async&&t(null,null)},normalizeFilename:function(e){return e},defs:[],plugins:{},fetchTimeout:1e3,dependencyBudget:2e4,reuseInstances:!0,stripCRs:!1,ecmaVersion:9,projectDir:"/",parent:null},u={completions:{takesFile:!0,run:function(i,s,e){if(null==s.end)throw j("missing .query.end field");var t=i.signalReturnFirst("completion",e,s);if(t)return t;var r=N(e,s.end),n=r,o=e.text;for(;r&&O.isIdentifierChar(o.charCodeAt(r-1));)--r;if(!1!==s.expandWordForward)for(;n<o.length&&O.isIdentifierChar(o.charCodeAt(n));)++n;var a,p,u,f,l=o.slice(r,n),c=[];s.caseInsensitive&&(l=l.toLowerCase());function h(e,t,r,n){var o;(!d&&!1===s.omitObjectPrototype||t!=i.cx.protos.Object||l)&&(!1!==s.filter&&l&&0!==(s.caseInsensitive?e.toLowerCase():e).indexOf(l)||a&&a.props[e]||(o=D(s,c,e,t&&t.props[e],r),n&&o&&"string"!=typeof o&&n(o)))}var g,d,y=T.findExpressionAround(e.ast,null,r,e.scope);if(y){var v,m,b=y.node;if(!1===s.inLiteral&&"Literal"===b.type&&("string"==typeof b.value||b.regex))return{start:F(s,e,r),end:F(s,e,n),completions:[]};"MemberExpression"==b.type&&b.object.end<r?g=y:!function(e,t,r){return"Literal"==e.type&&"string"==typeof e.value&&e.start==t-1&&e.end<=r+1}(b,r,n)?"ObjectExpression"==b.type&&((m=C(b,n))?(d=y,P=f=m.key.name||m.key.value):l||/:\s*$/.test(e.text.slice(0,r))||(d=y,P=f=!0)):"MemberExpression"==(v=T.parentNode(b,e.ast)).type&&v.property==b&&(g={node:v,state:y.state})}if(d)u=T.typeFromContext(e.ast,d),a=d.node.objType;else if(g)P="Literal"==(P=g.node.property).type?P.value.slice(1):P.name,g.node=g.node.object,u=T.expressionType(g);else if("."==o.charAt(r-1)){for(var w=r-1;w&&("."==o.charAt(w-1)||O.isIdentifierChar(o.charCodeAt(w-1)));)w--;var x=o.slice(w,r-1);x&&(u=T.def.parsePath(x,e.scope).getObjType(),P=l)}if(null!=P){if(i.cx.completingProperty=P,u&&T.forAllPropertiesOf(u,h),!c.length&&!1!==s.guess&&u&&u.guessProperties&&u.guessProperties(function(e,t,r){e!=P&&"✖"!=e&&"<i>"!=e&&h(e,t,r)}),!c.length&&2<=l.length&&!1!==s.guess)for(var P in i.cx.props)h(P,i.cx.props[P][0],0);p="memberCompletion"}else T.forAllLocalsAt(e.ast,r,e.scope,h),s.includeKeywords&&(6<=i.options.ecmaVersion?I:k).forEach(function(e){h(e,null,0,function(e){e.isKeyword=!0})}),p="variableCompletion";i.signal(p,e,r,n,h),!1!==s.sort&&c.sort(S);return i.cx.completingProperty=null,{start:F(s,e,r),end:F(s,e,n),isProperty:!!P,isObjectKey:!!f,completions:c}}},properties:{run:function(e,t){var r=t.prefix,n=[];for(var o in e.cx.props)"<i>"==o||r&&0!==o.indexOf(r)||n.push(o);!1!==t.sort&&n.sort(S);return{completions:n}}},type:{takesFile:!0,run:function(e,t,r){var n,o,i,s=L(r,t),a=H(e,t,r,s);(n=a[0])||(s=q(r,t),a=H(e,t,r,s),n=a[0]);o=a[1],i=a[2];var p={guess:T.didGuess(),type:T.toString(i,t.depth),name:n&&n.name,