PyConsoleStartFolding (boolean addOnce) { PyConsoleStartFolding startFolding = new PyConsoleStartFolding(this, addOnce); myExecuteActionHandler.getConsoleCommunication().addCommunicationListener(startFolding); Editor editor = getEditor(); if (editor == null) { return null; } editor.getDocument().addDocumentListener(startFolding); ((FoldingModelEx)editor.getFoldingModel()).addListener(startFolding, this); return startFolding; }