Buggy code:
public class FunctionInlineHandler implements InlineHandler { @ Nullable @ Override public Settings prepareInlineElement ( @ NotNull PsiElement element , @ Nullable Editor editor , boolean invokedOnReference ) { } private Settings toHardToInline ( PsiElement element , Editor editor ) { } @ Override public void removeDefinition ( @ NotNull PsiElement element , @ NotNull Settings settings ) { } @ Nullable @ Override public Inliner createInliner ( @ NotNull PsiElement element , @ NotNull Settings settings ) { if ( settings instanceof FunctionInlineHandler . FunctionSettings ) { FunctionInlineHandler . FunctionSettings functionSettings = ( ( FunctionInlineHandler . FunctionSettings ) ( settings ) ) ; return new Inliner ( ) { @ Nullable @ Override public MultiMap < PsiElement , String > getConflicts ( @ NotNull PsiReference reference , @ NotNull PsiElement referenced ) { return null ; } @ Override public void inlineUsage ( @ NotNull UsageInfo usage , @ NotNull PsiElement referenced ) { KerboScriptFile file = KerboScriptElementFactory . file ( referenced . getProject ( ) , functionSettings . returnStmt . getText ( ) ) ; ArrayList < ArrayList < PsiElement > > paramsUsages = new ArrayList < > ( ) ; for ( ArrayList < Integer > paramIndexes : functionSettings . paramUsages ) { ArrayList < PsiElement > paramUsages = new ArrayList < > ( ) ; for ( Integer index : paramIndexes ) { if ( index > 0 ) { PsiElement paramUsage = PsiTreeUtil . getParentOfType ( file . findElementAt ( index ) , KerboScriptExpr . class , false ) ; if ( paramUsage != null ) { paramUsages . add ( paramUsage ) ; } } } paramsUsages . add ( paramUsages ) ; } KerboScriptSuffixterm functionCall = PsiTreeUtil . getParentOfType ( usage . getElement ( ) , KerboScriptSuffixterm . class , false ) ; if ( functionCall != null ) { List < KerboScriptSuffixtermTrailer > trailers = functionCall . getSuffixtermTrailerList ( ) ; if ( ( trailers . size ( ) ) > 0 ) { KerboScriptSuffixtermTrailer trailer = trailers . get ( 0 ) ; if ( trailer instanceof KerboScriptFunctionTrailer ) { KerboScriptArglist arglist = ( ( KerboScriptFunctionTrailer ) ( trailer ) ) . getArglist ( ) ; if ( arglist != null ) { List < KerboScriptExpr > arguments = arglist . getExprList ( ) ; <START_BUG> for ( int i = 0 ; i < ( arguments . size ( ) ) ; i ++ ) { <END_BUG> KerboScriptExpr argument = arguments . get ( i ) ; ArrayList < PsiElement > paramUsages = paramsUsages . get ( i ) ; for ( PsiElement paramUsage : paramUsages ) { paramUsage . replace ( KerboScriptElementFactory . expression ( functionCall . getProject ( ) , ( ( "(" + ( argument . getText ( ) ) ) + ")" ) ) ) ; } } } } } KerboScriptReturnStmt returnStmt = ( ( KerboScriptReturnStmt ) ( file . getFirstChild ( ) ) ) ; KerboScriptExpr expression = returnStmt . getExpr ( ) ; if ( expression != null ) { functionCall . replace ( KerboScriptElementFactory . expression ( functionCall . getProject ( ) , ( ( "(" + ( expression . getText ( ) ) ) + ")" ) ) ) ; } } } } ; } return null ; } private static class FunctionSettings extends InlineSettings { private final ArrayList < ArrayList < Integer > > paramUsages = new ArrayList < > ( ) ; private KerboScriptReturnStmt returnStmt ; public FunctionSettings ( boolean onlyReference ) { } } }

Fix:
for ( int i = 0 ; i < ( Math . min ( arguments . size ( ) , paramsUsages . size ( ) ) ) ; i ++ ) {