版博士V2.0程序
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

comment.js 1.1 KiB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. "use strict";
  2. var _require = require('../constants/token-types'),
  3. TOKEN_COMMENT_START = _require.TOKEN_COMMENT_START,
  4. TOKEN_COMMENT_END = _require.TOKEN_COMMENT_END,
  5. TOKEN_COMMENT_CONTENT = _require.TOKEN_COMMENT_CONTENT;
  6. function handleCommentStart(state, token) {
  7. state.currentNode.content.start = token;
  8. state.caretPosition++;
  9. return state;
  10. }
  11. function handleCommentContent(state, token) {
  12. state.currentNode.content.value = token;
  13. state.caretPosition++;
  14. return state;
  15. }
  16. function handleCommentEnd(state, token) {
  17. state.currentNode.content.end = token;
  18. state.currentNode = state.currentNode.parentRef;
  19. state.currentContext = state.currentContext.parentRef;
  20. state.caretPosition++;
  21. return state;
  22. }
  23. module.exports = function comment(token, state) {
  24. if (token.type === TOKEN_COMMENT_START) {
  25. return handleCommentStart(state, token);
  26. }
  27. if (token.type === TOKEN_COMMENT_CONTENT) {
  28. return handleCommentContent(state, token);
  29. }
  30. if (token.type === TOKEN_COMMENT_END) {
  31. return handleCommentEnd(state, token);
  32. }
  33. state.caretPosition++;
  34. return state;
  35. };