CliOptions moved to the separate file
This commit is contained in:
@@ -38,7 +38,7 @@ import java.util.ServiceLoader
|
||||
import java.io.IOException
|
||||
import java.util.Enumeration
|
||||
import org.jetbrains.kotlin.compiler.plugin.parsePluginOption
|
||||
import org.jetbrains.kotlin.compiler.plugin.PluginOptionValue
|
||||
import org.jetbrains.kotlin.compiler.plugin.CliOptionValue
|
||||
|
||||
|
||||
public object PluginCliParser {
|
||||
@@ -75,7 +75,7 @@ public object PluginCliParser {
|
||||
|
||||
for (processor in commandLineProcessors) {
|
||||
val declaredOptions = processor.pluginOptions.valuesToMap { it.name }
|
||||
val optionsToValues = MultiMap<CliOption, PluginOptionValue>()
|
||||
val optionsToValues = MultiMap<CliOption, CliOptionValue>()
|
||||
|
||||
for (optionValue in optionValuesByPlugin[processor.pluginId].orEmpty()) {
|
||||
val option = declaredOptions[optionValue!!.optionName]
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright 2010-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.compiler.plugin
|
||||
|
||||
import org.jetbrains.jet.config.CompilerConfiguration
|
||||
import java.util.regex.Pattern
|
||||
|
||||
public class CliOption(
|
||||
public val name: String,
|
||||
public val valueDescription: String,
|
||||
public val description: String,
|
||||
public val required: Boolean = true,
|
||||
public val allowMultipleOccurrences: Boolean = false
|
||||
)
|
||||
|
||||
public class CliOptionProcessingException(message: String, cause: Throwable? = null): RuntimeException(message, cause)
|
||||
|
||||
public data class CliOptionValue(
|
||||
val pluginId: String,
|
||||
val optionName: String,
|
||||
val value: String
|
||||
) {
|
||||
override fun toString() = "$pluginId:$optionName=$value"
|
||||
}
|
||||
|
||||
public fun parsePluginOption(argumentValue: String): CliOptionValue? {
|
||||
val pattern = Pattern.compile("""^plugin:([^:]*):([^=]*)=(.*)$""")
|
||||
val matcher = pattern.matcher(argumentValue)
|
||||
if (matcher.matches()) {
|
||||
return CliOptionValue(matcher.group(1), matcher.group(2), matcher.group(3))
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
public fun getPluginOptionString(pluginId: String, key: String, value: String): String {
|
||||
return "plugin:$pluginId:$key=$value"
|
||||
}
|
||||
@@ -17,17 +17,6 @@
|
||||
package org.jetbrains.kotlin.compiler.plugin
|
||||
|
||||
import org.jetbrains.jet.config.CompilerConfiguration
|
||||
import java.util.regex.Pattern
|
||||
|
||||
public class CliOption(
|
||||
public val name: String,
|
||||
public val valueDescription: String,
|
||||
public val description: String,
|
||||
public val required: Boolean = true,
|
||||
public val allowMultipleOccurrences: Boolean = false
|
||||
)
|
||||
|
||||
public class CliOptionProcessingException(message: String, cause: Throwable? = null): RuntimeException(message, cause)
|
||||
|
||||
public trait CommandLineProcessor {
|
||||
public val pluginId: String
|
||||
@@ -35,26 +24,4 @@ public trait CommandLineProcessor {
|
||||
|
||||
[throws(javaClass<CliOptionProcessingException>())]
|
||||
public fun processOption(option: CliOption, value: String, configuration: CompilerConfiguration)
|
||||
}
|
||||
|
||||
public data class PluginOptionValue(
|
||||
val pluginId: String,
|
||||
val optionName: String,
|
||||
val value: String
|
||||
) {
|
||||
override fun toString() = "$pluginId:$optionName=$value"
|
||||
}
|
||||
|
||||
public fun parsePluginOption(argumentValue: String): PluginOptionValue? {
|
||||
val pattern = Pattern.compile("""^plugin:([^:]*):([^=]*)=(.*)$""")
|
||||
val matcher = pattern.matcher(argumentValue)
|
||||
if (matcher.matches()) {
|
||||
return PluginOptionValue(matcher.group(1), matcher.group(2), matcher.group(3))
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
public fun getPluginOptionString(pluginId: String, key: String, value: String): String {
|
||||
return "plugin:$pluginId:$key=$value"
|
||||
}
|
||||
Reference in New Issue
Block a user