void () { ProgressManager.checkCanceled(); String str = StringUtil.trimEnd(getPathString(), getSeparatorString()); List<FileReference> referencesList = new ArrayList<>(); String separatorString = getSeparatorString(); // separator's length can be more then 1 char int sepLen = separatorString.length(); int currentSlash = -sepLen; int startInElement = getStartInElement(); // skip white space while (currentSlash + sepLen < str.length() && Character.isWhitespace(str.charAt(currentSlash + sepLen))) { currentSlash++; } if (currentSlash + sepLen + sepLen < str.length() && str.substring(currentSlash + sepLen, currentSlash + sepLen + sepLen).equals(separatorString)) { currentSlash += sepLen; } int index = 0; if (str.equals(separatorString)) { FileReference fileReference = createFileReference( new TextRange(startInElement, startInElement + sepLen), index++, separatorString ); referencesList.add(fileReference); } while (true) { ProgressManager.checkCanceled(); int nextSlash = str.indexOf(separatorString, currentSlash + sepLen); String subReferenceText = nextSlash > 0 ? str.substring(0, nextSlash) : str; TextRange range = new TextRange(startInElement + currentSlash + sepLen, startInElement + (nextSlash > 0 ? nextSlash : str.length())); FileReference ref = createFileReference(range, index++, subReferenceText); referencesList.add(ref); if ((currentSlash = nextSlash) < 0) { break; } } myReferences = referencesList.toArray(FileReference.EMPTY); }