List<IndentGuideDescriptor> () { if (!myEditor.getSettings().isIndentGuidesShown()) return Collections.emptyList(); IndentsCalculator calculator = new IndentsCalculator(); calculator.calculate(); int[] lineIndents = calculator.lineIndents; IntStack lines = new IntArrayList(); IntStack indents = new IntArrayList(); lines.push(0); indents.push(0); List<IndentGuideDescriptor> descriptors = new ArrayList<>(); for (int line = 1; line < lineIndents.length; line++) { ProgressManager.checkCanceled(); int curIndent = Math.abs(lineIndents[line]); while (!indents.isEmpty() && curIndent <= indents.topInt()) { ProgressManager.checkCanceled(); int level = indents.popInt(); int startLine = lines.popInt(); if (level > 0) { for (int i = startLine; i < line; i++) { if (level != Math.abs(lineIndents[i])) { IndentGuideDescriptor descriptor = createDescriptor(level, startLine, line, lineIndents); if (IndentsPassFilterUtils.shouldShowIndentGuide(myEditor, descriptor)) descriptors.add(descriptor); break; } } } } int prevLine = line - 1; int prevIndent = Math.abs(lineIndents[prevLine]); if (curIndent - prevIndent > 1) { lines.push(prevLine); indents.push(prevIndent); } } while (!indents.isEmpty()) { ProgressManager.checkCanceled(); int level = indents.popInt(); int startLine = lines.popInt(); if (level > 0) { IndentGuideDescriptor descriptor = createDescriptor(level, startLine, myDocument.getLineCount(), lineIndents); if (IndentsPassFilterUtils.shouldShowIndentGuide(myEditor, descriptor)) descriptors.add(descriptor); } } return descriptors; }