void (@NotNull PsiElement appendLocation, @NotNull List<String> reusedVariables) { if (reusedVariables.isEmpty()) { return; } PsiElementFactory factory = JavaPsiFacade.getElementFactory(appendLocation.getProject()); for (String variable : reusedVariables) { PsiStatement declaration = factory.createStatementFromText(variable, appendLocation); appendLocation = appendLocation.getParent().addAfter(declaration, appendLocation); } }