Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

isReferenced.js 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = isReferenced;
  6. function isReferenced(node, parent, grandparent) {
  7. switch (parent.type) {
  8. case "MemberExpression":
  9. case "JSXMemberExpression":
  10. case "OptionalMemberExpression":
  11. if (parent.property === node) {
  12. return !!parent.computed;
  13. }
  14. return parent.object === node;
  15. case "VariableDeclarator":
  16. return parent.init === node;
  17. case "ArrowFunctionExpression":
  18. return parent.body === node;
  19. case "PrivateName":
  20. return false;
  21. case "ClassMethod":
  22. case "ClassPrivateMethod":
  23. case "ObjectMethod":
  24. if (parent.params.includes(node)) {
  25. return false;
  26. }
  27. case "ObjectProperty":
  28. case "ClassProperty":
  29. case "ClassPrivateProperty":
  30. if (parent.key === node) {
  31. return !!parent.computed;
  32. }
  33. if (parent.value === node) {
  34. return !grandparent || grandparent.type !== "ObjectPattern";
  35. }
  36. return true;
  37. case "ClassDeclaration":
  38. case "ClassExpression":
  39. return parent.superClass === node;
  40. case "AssignmentExpression":
  41. return parent.right === node;
  42. case "AssignmentPattern":
  43. return parent.right === node;
  44. case "LabeledStatement":
  45. return false;
  46. case "CatchClause":
  47. return false;
  48. case "RestElement":
  49. return false;
  50. case "BreakStatement":
  51. case "ContinueStatement":
  52. return false;
  53. case "FunctionDeclaration":
  54. case "FunctionExpression":
  55. return false;
  56. case "ExportNamespaceSpecifier":
  57. case "ExportDefaultSpecifier":
  58. return false;
  59. case "ExportSpecifier":
  60. if (grandparent != null && grandparent.source) {
  61. return false;
  62. }
  63. return parent.local === node;
  64. case "ImportDefaultSpecifier":
  65. case "ImportNamespaceSpecifier":
  66. case "ImportSpecifier":
  67. return false;
  68. case "JSXAttribute":
  69. return false;
  70. case "ObjectPattern":
  71. case "ArrayPattern":
  72. return false;
  73. case "MetaProperty":
  74. return false;
  75. case "ObjectTypeProperty":
  76. return parent.key !== node;
  77. case "TSEnumMember":
  78. return parent.id !== node;
  79. case "TSPropertySignature":
  80. if (parent.key === node) {
  81. return !!parent.computed;
  82. }
  83. return true;
  84. }
  85. return true;
  86. }