HighlightedInlays (Editor editor, int currentHintIndex, ParameterHintsPresentationManager presentationManager, int expressionCount, SmartPsiElementPointer<PsiExpressionList> exprListPtr) { PsiExpressionList expressionList = exprListPtr.getElement(); if (expressionList == null || editor.isDisposed()) return new HighlightedInlays(null, null); Inlay<?> currentHint = null; List<Inlay<?>> highlightedHints = new ArrayList<>(expressionCount); PsiElement prevDelimiter, nextDelimiter; for (int i = 0; i < Math.max(expressionCount, currentHintIndex == 0 ? 1 : 0); i++) { if (i < expressionCount) { PsiExpression expression = expressionList.getExpressions()[i]; prevDelimiter = expression; while (prevDelimiter != null && !(prevDelimiter instanceof PsiJavaToken)) { prevDelimiter = prevDelimiter.getPrevSibling(); } nextDelimiter = expression; while (nextDelimiter != null && !(nextDelimiter instanceof PsiJavaToken)) { nextDelimiter = nextDelimiter.getNextSibling(); } } else { prevDelimiter = expressionList.getFirstChild(); // left parenthesis nextDelimiter = expressionList.getLastChild(); // right parenthesis } if (prevDelimiter != null && nextDelimiter != null) { CharSequence text = editor.getDocument().getImmutableCharSequence(); int firstRangeStartOffset = prevDelimiter.getTextRange().getEndOffset(); int firstRangeEndOffset = CharArrayUtil.shiftForward(text, firstRangeStartOffset, WHITESPACE_OR_LINE_BREAKS); List<Inlay<?>> paramHintsInRange = presentationManager.getParameterHintsInRange(editor, firstRangeStartOffset, firstRangeEndOffset); for (Inlay<?> inlay : paramHintsInRange) { highlightedHints.add(inlay); if (i == currentHintIndex && currentHint == null) currentHint = inlay; } int secondRangeEndOffset = nextDelimiter.getTextRange().getStartOffset(); if (secondRangeEndOffset > firstRangeEndOffset) { int secondRangeStartOffset = CharArrayUtil.shiftBackward(text, secondRangeEndOffset - 1, WHITESPACE_OR_LINE_BREAKS) + 1; highlightedHints.addAll( presentationManager.getParameterHintsInRange(editor, secondRangeStartOffset, secondRangeEndOffset)); } } } return new HighlightedInlays(currentHint, highlightedHints); }