Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent tokens results for Term.ApplyInfix.args #1444

Closed
MasseGuillaume opened this issue Mar 20, 2018 · 1 comment
Closed

Inconsistent tokens results for Term.ApplyInfix.args #1444

MasseGuillaume opened this issue Mar 20, 2018 · 1 comment
Labels
Milestone

Comments

@MasseGuillaume
Copy link
Collaborator

MasseGuillaume commented Mar 20, 2018

def structure(source: String): String = 
  source.parse[Stat].get.asInstanceOf[Term.ApplyInfix].args.head.tokens.structure 

// This is what I get
structure("a op (f)") == "Tokens(( [5..6), f [6..7), ) [7..8))"

// This is what I expect
structure("a op (f)") == "Tokens(f [6..7))"

// With multiple args I get what I expect
structure("a op (f, g)") == "Tokens(f [6..7))"
@olafurpg
Copy link
Member

Duplicate of #1083, in scalafix we workaround the problem with

      val syntax = name.syntax
      // workaround for https://github.com/scalameta/scalameta/issues/1083
      val pos =
        if (syntax.startsWith("(") &&
          syntax.endsWith(")") &&
          syntax != name.value)
          Position.Range(name.pos.input, name.pos.start + 1, name.pos.end - 1)
        else name.pos

would be good to fix this at the root

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants