Skip to content

Commit

Permalink
♻ : remove redundant qualifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
juwit committed Sep 17, 2021
1 parent 8649046 commit be3273b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/main/java/io/gaia_app/hcl/HclParserImpl.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ class HclParserImpl : HclParser {
val charStream = CharStreams.fromString(content)

// configuring antlr lexer
val lexer = io.gaia_app.hcl.antlr.hclLexer(charStream)
val lexer = hclLexer(charStream)

// using the lexer to configure a token stream
val tokenStream = CommonTokenStream(lexer)

// configuring antlr parser using the token stream
val parser = io.gaia_app.hcl.antlr.hclParser(tokenStream)
val parser = hclParser(tokenStream)

// visit the AST
val hclVisitor = HclVisitor()
Expand Down
20 changes: 10 additions & 10 deletions src/main/java/io/gaia_app/hcl/HclVisitor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,50 +17,50 @@ class HclVisitor : io.gaia_app.hcl.antlr.hclBaseVisitor<Unit>() {
private var currentOutput: Output = Output()


override fun visitVariableDirective(ctx: io.gaia_app.hcl.antlr.hclParser.VariableDirectiveContext) {
override fun visitVariableDirective(ctx: hclParser.VariableDirectiveContext) {
currentVariable = Variable(name = ctx.STRING().text.removeSurrounding("\""))
variables.add(currentVariable)
visitChildren(ctx)
}

override fun visitVariableType(ctx: io.gaia_app.hcl.antlr.hclParser.VariableTypeContext) {
override fun visitVariableType(ctx: hclParser.VariableTypeContext) {
currentVariable.type = ctx.type().text.removeSurrounding("\"")
}

override fun visitVariableDefault(ctx: io.gaia_app.hcl.antlr.hclParser.VariableDefaultContext) {
override fun visitVariableDefault(ctx: hclParser.VariableDefaultContext) {
currentVariable.defaultValue = ctx.expression().text.removeSurrounding("\"")
}

override fun visitVariableDescription(ctx: io.gaia_app.hcl.antlr.hclParser.VariableDescriptionContext) {
override fun visitVariableDescription(ctx: hclParser.VariableDescriptionContext) {
currentVariable.description = ctx.STRING().text.removeSurrounding("\"")
}

override fun visitOutputDirective(ctx: io.gaia_app.hcl.antlr.hclParser.OutputDirectiveContext) {
override fun visitOutputDirective(ctx: hclParser.OutputDirectiveContext) {
currentOutput = Output(name = ctx.STRING().text.removeSurrounding("\""))
outputs.add(currentOutput)
visitChildren(ctx)
}

override fun visitOutputDescription(ctx: io.gaia_app.hcl.antlr.hclParser.OutputDescriptionContext) {
override fun visitOutputDescription(ctx: hclParser.OutputDescriptionContext) {
currentOutput.description = ctx.STRING().text.removeSurrounding("\"")
}

override fun visitOutputValue(ctx: io.gaia_app.hcl.antlr.hclParser.OutputValueContext) {
override fun visitOutputValue(ctx: hclParser.OutputValueContext) {
currentOutput.value = ctx.expression().text.removeSurrounding("\"")
}

override fun visitOutputSensitive(ctx: io.gaia_app.hcl.antlr.hclParser.OutputSensitiveContext) {
override fun visitOutputSensitive(ctx: hclParser.OutputSensitiveContext) {
currentOutput.sensitive = ctx.BOOLEAN().text.removeSurrounding("\"")
}

override fun visitProviderDirective(ctx: io.gaia_app.hcl.antlr.hclParser.ProviderDirectiveContext) {
override fun visitProviderDirective(ctx: hclParser.ProviderDirectiveContext) {
val parsedProvider = ctx.STRING().text.removeSurrounding("\"")
if (! IGNORED_PROVIDERS.contains(parsedProvider)) {
provider = parsedProvider
}
}

override fun visitResourceDirective(ctx: io.gaia_app.hcl.antlr.hclParser.ResourceDirectiveContext) {
override fun visitResourceDirective(ctx: hclParser.ResourceDirectiveContext) {
// provider already found !
if (provider != "unknown") return

Expand Down

0 comments on commit be3273b

Please sign in to comment.