VladRassokhin / intellij-hcl

HCL language support for IntelliJ platform based IDEs
Apache License 2.0
244 stars 47 forks source link

Feature - Refactoring - Extract to local variable #263

Open j-martin opened 5 years ago

j-martin commented 5 years ago

Just like you can currently extract strings to variables, it would be nice to be able to extract them as local variables instead.

image

This:

resource "null" "something" {
  value = "something"
}

Becomes:

locals {
  extracted_string = "something"
}

resource "null" "something" {
  value = local.extracted_string
}

It would be nice if there is already a locals block in the file that the variable gets added there. Even just putting it above the resource (data, etc.) like the extract variable currently does would be fine too.

To push things even further it would be nice the also have the ability to inline (opposite of extract) the variables (local or not) back where they came from.