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

Function findTypeAt

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

Source from the content-addressed store, hash-verified

878 };
879
880 function findTypeAt(srv, query, file) {
881 var expr = findExpr(file, query), exprName;
882 var type = findExprType(srv, query, file, expr), exprType = type;
883 if (query.preferFunction)
884 type = type.getFunctionType() || type.getType();
885 else
886 type = type.getType();
887
888 if (expr) {
889 if (expr.node.type == "Identifier")
890 exprName = expr.node.name;
891 else if (expr.node.type == "MemberExpression" && !expr.node.computed)
892 exprName = expr.node.property.name;
893 else if (expr.node.type == "MethodDefinition" && !expr.node.computed)
894 exprName = expr.node.key.name
895 }
896
897 if (query.depth != null && typeof query.depth != "number")
898 throw ternError(".query.depth must be a number");
899
900 var result = {guess: infer.didGuess(),
901 type: infer.toString(exprType, query.depth),
902 name: type && type.name,
903 exprName: exprName,
904 doc: exprType.doc,
905 url: exprType.url};
906 if (type) storeTypeDocs(query, type, result);
907
908 return clean(result);
909 }
910
911 function parseDoc(query, doc) {
912 if (!doc) return null;

Callers

nothing calls this directly

Calls 6

findExprTypeFunction · 0.85
ternErrorFunction · 0.85
storeTypeDocsFunction · 0.85
cleanFunction · 0.85
getTypeMethod · 0.80
toStringMethod · 0.45

Tested by

no test coverage detected