diff --git a/src/lib/contract/contract-comment.es6 b/src/lib/contract/contract-comment.es6 index 57f7853..6e1e094 100644 --- a/src/lib/contract/contract-comment.es6 +++ b/src/lib/contract/contract-comment.es6 @@ -34,10 +34,18 @@ export class ContractComment { let oldCommentPosition = line - 1; while (true) { let comment = this.contract.getLineAt(oldCommentPosition).trim(); - if (comment.startsWith(parameterCommentRegex)) { - oldCommentsParams.push({line: oldCommentPosition, value: comment}); + if (comment.startsWith('/**')) { + // multiline /** comments + return true; + } else if (comment.startsWith(parameterCommentRegex)) { + // param comments + oldCommentsParams.push({ line: oldCommentPosition, value: comment }); } else if (comment.startsWith('//')) { - oldCommentsMap[comment.match(generatedCommentRegex)[0]] = comment; + // other comments + let matchedComment = comment.match(generatedCommentRegex); + if (matchedComment != null) { + oldCommentsMap[matchedComment[0]] = comment; + } } else if (!comment.startsWith('function')) { break; } diff --git a/test/test-contracts/Metacoin.edited.commented.sol b/test/test-contracts/Metacoin.edited.commented.sol index 209f9cd..74d28dc 100644 --- a/test/test-contracts/Metacoin.edited.commented.sol +++ b/test/test-contracts/Metacoin.edited.commented.sol @@ -1,12 +1,19 @@ pragma solidity ^0.4.24; -/// @title MetaCoin v.2 +/** +* Different type of comments +* MetaCoin contract is used to.... +*/ contract MetaCoin { /// @notice mapping (address => uint) balances; + // @notice + // This is multiline comment + mapping (address => uint) tokens; + event Transfer(address _from,address _to, uint _amount); /// @notice @@ -16,6 +23,12 @@ contract MetaCoin { balances[tx.origin] = 10000; } + /// @param receiver + /// Another multiline comment, this one is about param receiver + function addToken(address receiver) public { + tokens[receiver] = tokens[receiver] + 1; + } + /// @notice /// @dev /// @param receiver diff --git a/test/test-contracts/Metacoin.edited.sol b/test/test-contracts/Metacoin.edited.sol index 2a5c016..5542b03 100644 --- a/test/test-contracts/Metacoin.edited.sol +++ b/test/test-contracts/Metacoin.edited.sol @@ -1,11 +1,18 @@ pragma solidity ^0.4.24; -/// @title MetaCoin v.2 +/** +* Different type of comments +* MetaCoin contract is used to.... +*/ contract MetaCoin { mapping (address => uint) balances; + // @notice + // This is multiline comment + mapping (address => uint) tokens; + event Transfer(address _from,address _to, uint _amount); /// @notice @@ -15,6 +22,12 @@ contract MetaCoin { balances[tx.origin] = 10000; } + /// @param receiver + /// Another multiline comment, this one is about param receiver + function addToken(address receiver) public { + tokens[receiver] = tokens[receiver] + 1; + } + /// @notice /// @dev /// @param receiver