2017-08-06 00:28:51 +08:00
|
|
|
package io.neoterm
|
|
|
|
|
|
|
|
import io.neoterm.frontend.config.ConfigVisitor
|
|
|
|
import io.neoterm.frontend.config.NeoConfigureFile
|
|
|
|
import org.junit.Test
|
2017-08-08 16:04:22 +08:00
|
|
|
import java.io.File
|
2017-08-06 00:28:51 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @author kiva
|
|
|
|
*/
|
|
|
|
class ConfigureFileTest {
|
|
|
|
private fun printAttr(visitor: ConfigVisitor, contextName: String, attrName: String) {
|
|
|
|
println("attr [$contextName->$attrName]: ${visitor.getAttribute(contextName, attrName).asString()}")
|
|
|
|
}
|
|
|
|
|
2017-08-08 16:04:22 +08:00
|
|
|
private fun parseConfigure(filePath: String, contextName: String, attrName: String) {
|
|
|
|
val config = NeoConfigureFile(File(filePath))
|
2017-08-06 00:28:51 +08:00
|
|
|
if (config.parseConfigure()) {
|
|
|
|
val visitor = config.getVisitor()
|
2017-08-08 16:04:22 +08:00
|
|
|
printAttr(visitor, contextName, attrName)
|
2017-08-06 00:28:51 +08:00
|
|
|
}
|
|
|
|
}
|
2017-08-08 16:04:22 +08:00
|
|
|
|
|
|
|
@Test
|
|
|
|
fun configureFileTest() {
|
|
|
|
// parseConfigure("NeoLang/example/color-scheme.nl", "colors", "foreground")
|
|
|
|
parseConfigure("NeoLang/example/extra-key.nl", "key", "0")
|
|
|
|
}
|
2017-08-06 00:28:51 +08:00
|
|
|
}
|