@@ -19,6 +19,20 @@ function isSandwichedMeishi({
19
19
}
20
20
return before . pos === "名詞" && after . pos === "名詞" ;
21
21
}
22
+ /**
23
+ * add two positions.
24
+ * note: line starts with 1, column starts with 0.
25
+ * @param {Position } base
26
+ * @param {Position } relative
27
+ * @return {Position }
28
+ */
29
+ function addPositions ( base , relative ) {
30
+ return {
31
+ line : base . line + relative . line - 1 , // line 1 + line 1 should be line 1
32
+ column : relative . line == 1 ? base . column + relative . column // when the same line
33
+ : relative . column // when another line
34
+ } ;
35
+ }
22
36
/**
23
37
* @param {RuleContext } context
24
38
* @param {object } options
@@ -78,10 +92,11 @@ export default function (context, options = {}) {
78
92
}
79
93
// report
80
94
if ( currentTenCount >= maxLen ) {
81
- let position = source . indexToPosition ( lastToken . word_position - 1 ) ;
95
+ let positionInSentence = source . indexToPosition ( lastToken . word_position - 1 ) ;
96
+ let positionInNode = addPositions ( sentence . loc . start , positionInSentence ) ;
82
97
let ruleError = new context . RuleError ( `一つの文で"、"を${ maxLen } つ以上使用しています` , {
83
- line : position . line - 1 ,
84
- column : position . column
98
+ line : positionInNode . line - 1 ,
99
+ column : positionInNode . column
85
100
} ) ;
86
101
report ( node , ruleError ) ;
87
102
currentTenCount = 0 ;
0 commit comments