@@ -10,6 +10,7 @@ import {
1010 createKeyFromKey ,
1111 restoreToSurfaceFromKey
1212} from "./token-utils" ;
13+
1314/**
1415 * Create token map object
1516 * {
@@ -30,6 +31,7 @@ function createSurfaceKeyMap(tokens) {
3031 return keyMap ;
3132 } , { } ) ;
3233}
34+
3335function matchExceptionRule ( tokens ) {
3436 let token = tokens [ 0 ] ;
3537 // "の" の重なりは例外
@@ -46,6 +48,7 @@ function matchExceptionRule(tokens) {
4648 }
4749 return false ;
4850}
51+
4952/*
5053 default options
5154 */
@@ -64,7 +67,7 @@ const defaultOptions = {
6467
6568 TODO: need abstraction
6669 */
67- module . exports = function ( context , options = { } ) {
70+ module . exports = function ( context , options = { } ) {
6871 const helper = new RuleHelper ( context ) ;
6972 // 最低間隔値
7073 const minInterval = options . min_interval || defaultOptions . min_interval ;
@@ -73,7 +76,7 @@ module.exports = function(context, options = {}) {
7376 const separatorChars = options . separatorChars || defaultOptions . separatorChars ;
7477 const { Syntax, report, RuleError} = context ;
7578 return {
76- [ Syntax . Paragraph ] ( node ) {
79+ [ Syntax . Paragraph ] ( node ) {
7780 if ( helper . isChildNode ( node , [ Syntax . Link , Syntax . Image , Syntax . BlockQuote , Syntax . Emphasis ] ) ) {
7881 return ;
7982 }
@@ -136,15 +139,13 @@ module.exports = function(context, options = {}) {
136139 // 助詞token同士の距離が設定値以下ならエラーを報告する
137140 const differenceIndex = otherPosition - startPosition ;
138141 if ( differenceIndex <= minInterval ) {
139- const originalIndex = source . originalIndexFromPosition ( {
140- line : sentence . loc . start . line ,
141- column : sentence . loc . start . column + ( current . word_position - 1 )
142- } ) ;
143142 // padding positionを計算する
144- const padding = {
143+ const originalIndex = source . originalIndexFromIndex (
144+ sentence . range [ 0 ] + ( current . word_position - 1 )
145+ ) ;
146+ report ( node , new RuleError ( `一文に二回以上利用されている助詞 "${ joshiName } " がみつかりました。` , {
145147 index : originalIndex
146- } ;
147- report ( node , new RuleError ( `一文に二回以上利用されている助詞 "${ joshiName } " がみつかりました。` , padding ) ) ;
148+ } ) ) ;
148149 }
149150 return current ;
150151 } ) ;
0 commit comments