in src/main/kotlin/mobi/hsz/idea/gitignore/reference/IgnoreReferenceSet.kt [50:89]
override fun reparse() {
ProgressManager.checkCanceled()
val str = StringUtil.trimEnd(pathString, separatorString)
val referencesList: MutableList<FileReference?> = ArrayList()
val separatorString = separatorString // separator's length can be more then 1 char
val sepLen = separatorString.length
var currentSlash = -sepLen
val startInElement = startInElement
// skip white space
while (currentSlash + sepLen < str.length && Character.isWhitespace(str[currentSlash + sepLen])) {
currentSlash++
}
if (currentSlash + sepLen + sepLen < str.length &&
str.substring(currentSlash + sepLen, currentSlash + sepLen + sepLen) == separatorString
) {
currentSlash += sepLen
}
var index = 0
if (str == separatorString) {
val fileReference = createFileReference(TextRange(startInElement, startInElement + sepLen), index++, separatorString)
referencesList.add(fileReference)
}
while (true) {
ProgressManager.checkCanceled()
val nextSlash = str.indexOf(separatorString, currentSlash + sepLen)
val subReferenceText = if (nextSlash > 0) str.substring(0, nextSlash) else str
val range = TextRange(
startInElement + currentSlash + sepLen,
startInElement +
if (nextSlash > 0) nextSlash else str.length
)
val ref = createFileReference(range, index++, subReferenceText)
referencesList.add(ref)
if (nextSlash.also { currentSlash = it } < 0) {
break
}
}
myReferences = referencesList.toTypedArray()
}