Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

definition.js 2.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  2. Copyright (C) 2015 Yusuke Suzuki <utatane.tea@gmail.com>
  3. Redistribution and use in source and binary forms, with or without
  4. modification, are permitted provided that the following conditions are met:
  5. * Redistributions of source code must retain the above copyright
  6. notice, this list of conditions and the following disclaimer.
  7. * Redistributions in binary form must reproduce the above copyright
  8. notice, this list of conditions and the following disclaimer in the
  9. documentation and/or other materials provided with the distribution.
  10. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  11. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  12. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  13. ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
  14. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  15. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  16. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  17. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  18. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  19. THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  20. */
  21. "use strict";
  22. const Variable = require("./variable");
  23. /**
  24. * @class Definition
  25. */
  26. class Definition {
  27. constructor(type, name, node, parent, index, kind) {
  28. /**
  29. * @member {String} Definition#type - type of the occurrence (e.g. "Parameter", "Variable", ...).
  30. */
  31. this.type = type;
  32. /**
  33. * @member {espree.Identifier} Definition#name - the identifier AST node of the occurrence.
  34. */
  35. this.name = name;
  36. /**
  37. * @member {espree.Node} Definition#node - the enclosing node of the identifier.
  38. */
  39. this.node = node;
  40. /**
  41. * @member {espree.Node?} Definition#parent - the enclosing statement node of the identifier.
  42. */
  43. this.parent = parent;
  44. /**
  45. * @member {Number?} Definition#index - the index in the declaration statement.
  46. */
  47. this.index = index;
  48. /**
  49. * @member {String?} Definition#kind - the kind of the declaration statement.
  50. */
  51. this.kind = kind;
  52. }
  53. }
  54. /**
  55. * @class ParameterDefinition
  56. */
  57. class ParameterDefinition extends Definition {
  58. constructor(name, node, index, rest) {
  59. super(Variable.Parameter, name, node, null, index, null);
  60. /**
  61. * Whether the parameter definition is a part of a rest parameter.
  62. * @member {boolean} ParameterDefinition#rest
  63. */
  64. this.rest = rest;
  65. }
  66. }
  67. module.exports = {
  68. ParameterDefinition,
  69. Definition
  70. };
  71. /* vim: set sw=4 ts=4 et tw=80 : */