VladRassokhin / intellij-hcl

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

Values within parentheses are not indendet correctly #269

Closed G-Rath closed 3 years ago

G-Rath commented 4 years ago

Prerequisites

Installation details

IntelliJ IDEA 2019.2.4 Preview (Ultimate Edition) Build #IU-192.7142.17, built on October 16, 2019 Licensed to Gareth Jones Subscription is active until June 22, 2020 Runtime version: 11.0.2+9-b226.7 amd64 VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o Windows 10 10.0 GC: ParNew, ConcurrentMarkSweep Memory: 1981M Cores: 8 Registry: analyze.exceptions.on.the.fly=true, java.completion.argument.hints.internal=false, git.use.builtin.ssh=true, debugger.watches.in.variables=false, completion.stats.show.ml.ranking.diff=true Non-Bundled Plugins: CMD Support, Key Promoter X, PsiViewer, Switch Structure, com.alayouni.ansiHighlight, com.intellij.apacheConfig, com.jetbrains.foldOtherMethods, com.jetbrains.plugins.ini4idea, com.intellij.plugins.watcher, com.jetbrains.upsource, lermitage.intellij.battery.status, mobi.hsz.idea.gitignore, net.seesharpsoft.intellij.plugins.csv, net.vektah.codeglance, org.asciidoctor.intellij.asciidoc, org.elixir_lang, org.intellij.plugins.hcl, org.jetbrains.plugins.ruby-chef, Karma, org.jetbrains.kotlin, com.developerphil.adbidea, com.dmarcotte.handlebars, com.intellij.lang.jsgraphql, com.intellij.plugins.html.instantEditing, com.intellij.plugins.webcomponents, com.jetbrains.lang.ejs, com.jetbrains.plugins.jade, com.jetbrains.php, com.jetbrains.php.blade, com.jetbrains.php.drupal, com.jetbrains.php.wordPress, com.jetbrains.twig, de.espend.idea.laravel, net.king2500.plugins.PhpAdvancedAutoComplete, cucumber-javascript, intellij.prettierJS, org.intellij.scala, org.jetbrains.plugins.go, org.jetbrains.plugins.phpstorm-remote-interpreter, org.jetbrains.plugins.vagrant, org.jetbrains.plugins.vue, Dart, io.flutter, org.jetbrains.plugins.node-remote-interpreter, Pythonid, com.emberjs, com.raket.silverstripe, org.jetbrains.plugins.ruby, jones.foldtestblocks.fold-test-blocks, org.psliwa.idea.composer, org.sylfra.idea.plugins.linessorter, org.toml.lang, org.rust.lang, ru.adelf.idea.dotenv, uk.co.ben-gibson.remote.repository.mapper

intellij-hcl plugin version: 0.7.7 Terraform version: 0.12.12

Terraform Configuration Files

resource "aws_iam_role" "execution" {
assume_role_policy = data.aws_iam_policy_document.fargate_execution_assume_role.json
name               = "${var.env_name}-execution-role"

tags = merge(
var.common_tags,
{
Name = "${var.env_slug}-execution-role"
},
)
}

locals {
task_definition_revision = max(
aws_ecs_task_definition.app_task.revision,
data.aws_ecs_task_definition.app_task.revision
)
}

Expected Behavior

resource "aws_iam_role" "execution" {
  assume_role_policy = data.aws_iam_policy_document.fargate_execution_assume_role.json
  name               = "${var.env_name}-execution-role"

  tags = merge(
    var.common_tags,
    {
      Name = "${var.env_slug}-execution-role"
    },
  )
}

locals {
  task_definition_revision = max(
    aws_ecs_task_definition.app_task.revision,
    data.aws_ecs_task_definition.app_task.revision
  )
}

Actual Behavior

resource "aws_iam_role" "execution" {
  assume_role_policy = data.aws_iam_policy_document.fargate_execution_assume_role.json
  name               = "${var.env_name}-execution-role"

  tags = merge(
  var.common_tags,
  {
    Name = "${var.env_slug}-execution-role"
  },
  )
}

locals {
  task_definition_revision = max(
  aws_ecs_task_definition.app_task.revision,
  data.aws_ecs_task_definition.app_task.revision
  )
}

Steps to Reproduce

  1. Apply formatting to above code

For reference, [] are indented fine, but () are not. Hopefully that means it's an easy-ish fix, since () isn't actually used much already in Terraform, so it shouldn't impact any existing formatting?

Looking at the code preview in the styles panel, I think it might be just that () has been overlooked, as none of the code previews has function calls.

G-Rath commented 4 years ago

@VladRassokhin I know this closed-source, and I think you're maybe NDA-bound to not talk that? but if it would help, I'm happy to take a crack at solving this w/ the current codebase, given that I think the solution should be fairly isolated from any of the new changes (unless there was some big overhaul).

Eitherway, would be super cool to get this one fixed & released, as for me it's pretty much my biggest pain point as it's the biggest difference I know of vs terraform fmt 😬

VladRassokhin commented 3 years ago

I think you're maybe NDA-bound to not talk that? Nope :) I'm just too busy with other things.

Anyway will be fixed in 0.7.15 (not released yet)

G-Rath commented 2 years ago

@VladRassokhin thanks! It seems that this still happens with for statements however, so I've opened #378.

I'm just too busy with other things.

I'm sorry to hear that - given the amount of time I spend writing Terraform, I'd be happy to help maintain this plugin with you (& JetBrains) if you want. I think I've already identified a couple of fixes for some minor bugs that I'd love to land.