MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / findExprType

Function findExprType

lib/web/tern/tern.js:850–878  ·  view source on GitHub ↗
(srv, query, file, expr)

Source from the content-addressed store, hash-verified

848 }
849
850 function findExprType(srv, query, file, expr) {
851 var type;
852 if (expr) {
853 infer.resetGuessing();
854 type = infer.expressionType(expr);
855 }
856 var typeHandlers = srv.hasHandler("typeAt")
857 if (typeHandlers) {
858 var pos = resolvePos(file, query.end)
859 for (var i = 0; i < typeHandlers.length; i++)
860 type = typeHandlers[i](file, pos, expr, type)
861 }
862 if (!type) throw ternError("No type found at the given position.");
863
864 var objProp;
865 if (expr.node.type == "ObjectExpression" && query.end != null &&
866 (objProp = pointInProp(expr.node, resolvePos(file, query.end)))) {
867 var name = objProp.key.name;
868 var fromCx = ensureObj(infer.typeFromContext(file.ast, expr));
869 if (fromCx && fromCx.hasProp(name)) {
870 type = fromCx.hasProp(name);
871 } else {
872 var fromLocal = ensureObj(type);
873 if (fromLocal && fromLocal.hasProp(name))
874 type = fromLocal.hasProp(name);
875 }
876 }
877 return type;
878 };
879
880 function findTypeAt(srv, query, file) {
881 var expr = findExpr(file, query), exprName;

Callers 3

findTypeAtFunction · 0.85
findDocsFunction · 0.85
findDefFunction · 0.85

Calls 3

ternErrorFunction · 0.85
pointInPropFunction · 0.85
ensureObjFunction · 0.85

Tested by

no test coverage detected