List<PsiReference> (@NotNull PsiElement anchor, @NotNull Substring s, int offset) { final List<PsiReference> result = new ArrayList<>(); final PyTypeParser.ParseResult parseResult = PyTypeParser.parse(anchor, s.toString()); final Map<TextRange, ? extends PyType> types = parseResult.getTypes(); if (types.isEmpty()) { result.add(new DocStringTypeReference(anchor, s.getTextRange().shiftRight(offset), s.getTextRange().shiftRight(offset), null, null)); } offset = s.getTextRange().getStartOffset() + offset; final Map<? extends PyType, TextRange> fullRanges = parseResult.getFullRanges(); for (Map.Entry<TextRange, ? extends PyType> pair : types.entrySet()) { final PyType t = pair.getValue(); final TextRange range = pair.getKey().shiftRight(offset); final TextRange fullRange = fullRanges.containsKey(t) ? fullRanges.get(t).shiftRight(offset) : range; final PyImportElement importElement = parseResult.getImports().get(t); result.add(new DocStringTypeReference(anchor, range, fullRange, t, importElement)); } return result; }