1
- import { pad } from '../utils/string-utils' ;
1
+ import { pad } from '../utils/string-utils' ;
2
2
import CommentsGenerator from '../generators/comments-generator' ;
3
3
4
4
// regexps
@@ -31,11 +31,11 @@ export class ContractComment {
31
31
// extract old comments
32
32
let oldCommentsParams = [ ] ;
33
33
let oldCommentsMap = { } ;
34
- let oldCommentPosition = line - 2 ;
34
+ let oldCommentPosition = line - 1 ;
35
35
while ( true ) {
36
36
let comment = this . contract . getLineAt ( oldCommentPosition ) . trim ( ) ;
37
37
if ( comment . startsWith ( parameterCommentRegex ) ) {
38
- oldCommentsParams . push ( { line : oldCommentPosition , value : comment } ) ;
38
+ oldCommentsParams . push ( { line : oldCommentPosition , value : comment } ) ;
39
39
} else if ( comment . startsWith ( '//' ) ) {
40
40
oldCommentsMap [ comment . match ( generatedCommentRegex ) [ 0 ] ] = comment ;
41
41
} else if ( ! comment . startsWith ( 'function' ) ) {
@@ -58,16 +58,12 @@ export class ContractComment {
58
58
} , { } ) ;
59
59
// update params if changed
60
60
if ( newCommentsParams . length ) {
61
- for ( let k in oldCommentsMap ) {
62
- const c = ! k ;
63
- if ( c in newCommentsMap ) {
64
- return true ;
65
- }
61
+ if ( Object . keys ( oldCommentsMap ) . length !== Object . keys ( newCommentsMap ) . length ) {
62
+ return true ;
66
63
}
67
64
let firstCommentLine = oldCommentsParams
68
65
. reduce ( ( min , b ) => Math . min ( min , b . line ) , oldCommentsParams [ 0 ] . line ) ;
69
- // remove old params comments and save additional information about
70
- // params
66
+ // remove old params comments and save addi. information about params
71
67
let savedComments = { } ;
72
68
for ( let oldComment of oldCommentsParams ) {
73
69
this . contract . removeLine ( firstCommentLine ) ;
0 commit comments