override fun close()

in intellij-plugin-structure/structure-base/src/main/kotlin/com/jetbrains/plugin/structure/xml/CountingXmlEventWriter.kt [46:70]


  override fun close() {
    if ((eventCounter.size == 1 && startDocuments() == 1)
      || (eventCounter.size == 1 && processingInstructions() > 0)
      || eventCounter.isEmpty()
      || hasOnlyPrologEvents()
      ) {
      // closing without an actual document being written
      try {
        delegate.close()
      } catch (e: Exception) {
        when (e) {
          is RuntimeException, is XMLStreamException -> {
            LOG.error("Failed to close delegate XML event writer: {}", e.message)
            return
          }
        }
      }
    } else {
      try {
        delegate.close()
      } catch (e: Exception) {
        throw e
      }
    }
  }