|
| 1 | +const { |
| 2 | + handleOwnLineComment, |
| 3 | + handleEndOfLineComment, |
| 4 | + handleRemainingComment, |
| 5 | + isBlockComment |
| 6 | +} = require('../prettier-comments/language-js/comments'); |
| 7 | + |
| 8 | +const handleContractDefinitionComments = require('./handlers/ContractDefinition'); |
| 9 | + |
| 10 | +function solidityHandleOwnLineComment( |
| 11 | + comment, |
| 12 | + text, |
| 13 | + options, |
| 14 | + ast, |
| 15 | + isLastComment |
| 16 | +) { |
| 17 | + const { precedingNode, enclosingNode, followingNode } = comment; |
| 18 | + const handlerArguments = [ |
| 19 | + text, |
| 20 | + precedingNode, |
| 21 | + enclosingNode, |
| 22 | + followingNode, |
| 23 | + comment, |
| 24 | + options |
| 25 | + ]; |
| 26 | + |
| 27 | + if ( |
| 28 | + handleContractDefinitionComments(...handlerArguments) || |
| 29 | + handleOwnLineComment(comment, text, options, ast, isLastComment) |
| 30 | + ) { |
| 31 | + return true; |
| 32 | + } |
| 33 | + return false; |
| 34 | +} |
| 35 | + |
| 36 | +function solidityHandleEndOfLineComment( |
| 37 | + comment, |
| 38 | + text, |
| 39 | + options, |
| 40 | + ast, |
| 41 | + isLastComment |
| 42 | +) { |
| 43 | + const { precedingNode, enclosingNode, followingNode } = comment; |
| 44 | + const handlerArguments = [ |
| 45 | + text, |
| 46 | + precedingNode, |
| 47 | + enclosingNode, |
| 48 | + followingNode, |
| 49 | + comment, |
| 50 | + options |
| 51 | + ]; |
| 52 | + |
| 53 | + if ( |
| 54 | + handleContractDefinitionComments(...handlerArguments) || |
| 55 | + handleEndOfLineComment(comment, text, options, ast, isLastComment) |
| 56 | + ) { |
| 57 | + return true; |
| 58 | + } |
| 59 | + return false; |
| 60 | +} |
| 61 | + |
| 62 | +function solidityHandleRemainingComment( |
| 63 | + comment, |
| 64 | + text, |
| 65 | + options, |
| 66 | + ast, |
| 67 | + isLastComment |
| 68 | +) { |
| 69 | + const { precedingNode, enclosingNode, followingNode } = comment; |
| 70 | + const handlerArguments = [ |
| 71 | + text, |
| 72 | + precedingNode, |
| 73 | + enclosingNode, |
| 74 | + followingNode, |
| 75 | + comment, |
| 76 | + options |
| 77 | + ]; |
| 78 | + |
| 79 | + if ( |
| 80 | + handleContractDefinitionComments(...handlerArguments) || |
| 81 | + handleRemainingComment(comment, text, options, ast, isLastComment) |
| 82 | + ) { |
| 83 | + return true; |
| 84 | + } |
| 85 | + return false; |
| 86 | +} |
| 87 | + |
| 88 | +module.exports = { |
| 89 | + handleOwnLineComment: solidityHandleOwnLineComment, |
| 90 | + handleEndOfLineComment: solidityHandleEndOfLineComment, |
| 91 | + handleRemainingComment: solidityHandleRemainingComment, |
| 92 | + isBlockComment |
| 93 | +}; |
0 commit comments