private void adjustASIAndCollectFollowElements(CustomInternalN4JSParser previousParser,boolean strict,Set<FollowElement> result){
  ObservableXtextTokenStream tokens=(ObservableXtextTokenStream)previousParser.getTokenStream();
  int lastTokenIndex=tokens.size() - 1;
  if (lastTokenIndex >= 0) {
    CommonToken lastToken=(CommonToken)tokens.LT(-1);
    @SuppressWarnings("unchecked") List<Token> tokenList=tokens.getTokens();
    if (lastToken == null) {
      return;
    }
    if (shouldSkipASI(lastToken)) {
      if (maySkipASI(lastToken,tokens)) {
        tokenList.remove(lastTokenIndex);
        result.addAll(resetAndGetFollowElements(tokens,strict));
        removePostfixOperator(result);
      }
    }
 else     if (shouldAddSyntheticSemicolon(previousParser,lastTokenIndex,lastToken)) {
      CommonToken token=new CommonToken(semi);
      tokenList.add(token);
      result.addAll(resetAndGetFollowElements(tokens,strict));
      removePostfixOperator(result);
    }
  }
}

private void adjustASIAndCollectFollowElements ( CustomInternalN4JSParser previousParser , boolean strict , Set < FollowElement > result ) { ObservableXtextTokenStream tokens = ( ObservableXtextTokenStream ) previousParser . getTokenStream ( ) ; int lastTokenIndex = tokens . size ( ) - 1 ; if ( lastTokenIndex >= 0 ) { CommonToken lastToken = ( CommonToken ) tokens . LT ( - 1 ) ; @ SuppressWarnings ( "unchecked" ) List < Token > tokenList = tokens . getTokens ( ) ; if ( lastToken == null ) { return ; } if ( shouldSkipASI ( lastToken ) ) { if ( maySkipASI ( lastToken , tokens ) ) { tokenList . remove ( lastTokenIndex ) ; result . addAll ( resetAndGetFollowElements ( tokens , strict ) ) ; removePostfixOperator ( result ) ; } } else if ( shouldAddSyntheticSemicolon ( previousParser , lastTokenIndex , lastToken ) ) { CommonToken token = new CommonToken ( semi ) ; tokenList . add ( token ) ; result . addAll ( resetAndGetFollowElements ( tokens , strict ) ) ; removePostfixOperator ( result ) ; } } }
the second pass over the given input . if the input ends with an asi , the semicolon is removed and it is parsed again since the production may have skipped the asi if more input was present . same applies for the opposite direction , e . g if it does not end with an asi but the prev token suggests that there may have been a semicolon , it is inserted .
