All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.jetbrains.plugin.structure.intellij.verifiers.SimpleVerifiers.kt Maven / Gradle / Ivy

Go to download

Library for parsing JetBrains IDE plugins. Can be used to verify that plugin complies with the JetBrains Marketplace requirements.

There is a newer version: 3.290
Show newest version
package com.jetbrains.plugin.structure.intellij.verifiers

import com.jetbrains.plugin.structure.base.problems.ContainsNewlines
import com.jetbrains.plugin.structure.base.problems.TooLongPropertyValue
import com.jetbrains.plugin.structure.intellij.plugin.IdePluginManager.Companion.PLUGIN_XML

const val MAX_PROPERTY_LENGTH = 255

fun verifyNewlines(propertyName: String, propertyValue: String,
                   descriptorPath: String = PLUGIN_XML,
                   problemRegistrar: ProblemRegistrar) {
  if (propertyValue.trim().contains("\n")) {
    problemRegistrar.registerProblem(ContainsNewlines(propertyName, descriptorPath))
  }
}

fun verifyPropertyLength(propertyName: String, propertyValue: String, maxLength: Int,
                         descriptorPath: String = PLUGIN_XML, problemRegistrar: ProblemRegistrar) {
  if (propertyValue.length > maxLength) {
    problemRegistrar.registerProblem(TooLongPropertyValue(descriptorPath, propertyName, propertyValue.length, maxLength))
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy