@@ -697,25 +697,20 @@ public JsonToken nextToken() throws IOException
697
697
close ();
698
698
return (_currToken = null );
699
699
}
700
-
701
- // First, need to ensure we know the starting location of token
702
- // after skipping leading white space
703
- _tokenInputTotal = _currInputProcessed + _inputPtr - 1 ;
704
- _tokenInputRow = _currInputRow ;
705
- _tokenInputCol = _inputPtr - _currInputRowStart - 1 ;
706
-
707
- // finally: clear any data retained so far
700
+ // clear any data retained so far
708
701
_binaryValue = null ;
709
702
710
703
// Closing scope?
711
704
if (i == INT_RBRACKET ) {
705
+ _updateLocationFromInputPtr ();
712
706
if (!_parsingContext .inArray ()) {
713
707
_reportMismatchedEndMarker (i , '}' );
714
708
}
715
709
_parsingContext = _parsingContext .getParent ();
716
710
return (_currToken = JsonToken .END_ARRAY );
717
711
}
718
712
if (i == INT_RCURLY ) {
713
+ _updateLocationFromInputPtr ();
719
714
if (!_parsingContext .inObject ()) {
720
715
_reportMismatchedEndMarker (i , ']' );
721
716
}
@@ -730,6 +725,7 @@ public JsonToken nextToken() throws IOException
730
725
}
731
726
i = _skipWS ();
732
727
}
728
+ _updateLocationFromInputPtr ();
733
729
734
730
/* And should we now have a name? Always true for
735
731
* Object contexts, since the intermediate 'expect-value'
@@ -848,6 +844,9 @@ private final JsonToken _nextAfterName()
848
844
_nameCopied = false ; // need to invalidate if it was copied
849
845
JsonToken t = _nextToken ;
850
846
_nextToken = null ;
847
+
848
+ // !!! 16-Nov-2015, tatu: TODO: fix [databind#37], copy next location to current here
849
+
851
850
// Also: may need to start new context?
852
851
if (t == JsonToken .START_ARRAY ) {
853
852
_parsingContext = _parsingContext .createChildArrayContext (_tokenInputRow , _tokenInputCol );
@@ -867,7 +866,6 @@ private final JsonToken _nextAfterName()
867
866
public boolean nextFieldName (SerializableString str ) throws IOException
868
867
{
869
868
// // // Note: most of code below is copied from nextToken()
870
-
871
869
_numTypesValid = NR_UNKNOWN ;
872
870
if (_currToken == JsonToken .FIELD_NAME ) { // can't have name right after name
873
871
_nextAfterName ();
@@ -882,15 +880,11 @@ public boolean nextFieldName(SerializableString str) throws IOException
882
880
_currToken = null ;
883
881
return false ;
884
882
}
885
- _tokenInputTotal = _currInputProcessed + _inputPtr - 1 ;
886
- _tokenInputRow = _currInputRow ;
887
- _tokenInputCol = _inputPtr - _currInputRowStart - 1 ;
888
-
889
- // finally: clear any data retained so far
890
883
_binaryValue = null ;
891
884
892
885
// Closing scope?
893
886
if (i == INT_RBRACKET ) {
887
+ _updateLocationFromInputPtr ();
894
888
if (!_parsingContext .inArray ()) {
895
889
_reportMismatchedEndMarker (i , '}' );
896
890
}
@@ -899,6 +893,7 @@ public boolean nextFieldName(SerializableString str) throws IOException
899
893
return false ;
900
894
}
901
895
if (i == INT_RCURLY ) {
896
+ _updateLocationFromInputPtr ();
902
897
if (!_parsingContext .inObject ()) {
903
898
_reportMismatchedEndMarker (i , ']' );
904
899
}
@@ -915,6 +910,7 @@ public boolean nextFieldName(SerializableString str) throws IOException
915
910
i = _skipWS ();
916
911
}
917
912
913
+ _updateLocationFromInputPtr ();
918
914
if (!_parsingContext .inObject ()) {
919
915
_nextTokenNotInObject (i );
920
916
return false ;
@@ -971,13 +967,10 @@ public String nextFieldName() throws IOException
971
967
_currToken = null ;
972
968
return null ;
973
969
}
974
- _tokenInputTotal = _currInputProcessed + _inputPtr - 1 ;
975
- _tokenInputRow = _currInputRow ;
976
- _tokenInputCol = _inputPtr - _currInputRowStart - 1 ;
977
-
978
970
_binaryValue = null ;
979
971
980
972
if (i == INT_RBRACKET ) {
973
+ _updateLocationFromInputPtr ();
981
974
if (!_parsingContext .inArray ()) {
982
975
_reportMismatchedEndMarker (i , '}' );
983
976
}
@@ -986,6 +979,7 @@ public String nextFieldName() throws IOException
986
979
return null ;
987
980
}
988
981
if (i == INT_RCURLY ) {
982
+ _updateLocationFromInputPtr ();
989
983
if (!_parsingContext .inObject ()) {
990
984
_reportMismatchedEndMarker (i , ']' );
991
985
}
@@ -1001,7 +995,7 @@ public String nextFieldName() throws IOException
1001
995
}
1002
996
i = _skipWS ();
1003
997
}
1004
-
998
+ _updateLocationFromInputPtr ();
1005
999
if (!_parsingContext .inObject ()) {
1006
1000
_nextTokenNotInObject (i );
1007
1001
return null ;
@@ -3608,6 +3602,20 @@ protected final byte[] _decodeBase64(Base64Variant b64variant) throws IOExceptio
3608
3602
}
3609
3603
}
3610
3604
3605
+ /*
3606
+ /**********************************************************
3607
+ /* Internal methods, location updating (refactored in 2.7)
3608
+ /**********************************************************
3609
+ */
3610
+
3611
+ // @since 2.7
3612
+ private final void _updateLocationFromInputPtr ()
3613
+ {
3614
+ _tokenInputTotal = _currInputProcessed + _inputPtr - 1 ;
3615
+ _tokenInputRow = _currInputRow ;
3616
+ _tokenInputCol = _inputPtr - _currInputRowStart - 1 ;
3617
+ }
3618
+
3611
3619
/*
3612
3620
/**********************************************************
3613
3621
/* Internal methods, other
0 commit comments