OyvindSabo / gremlint

Linter/Code formatter for Gremlin
https://gremlint.com
Apache License 2.0
11 stars 6 forks source link

Distinguish individual codeblocks based on whether they can be parsed as Gremlin, not on linebreak. #69

Closed OyvindSabo closed 3 years ago

OyvindSabo commented 3 years ago

Consider the following query which we want to format with a max line length of 45:

a = 4.5;
b = 4.5;

g.V(ids).
has('factor_a').
has('factor_b').
project('Factor A', 'Factor B', 'Product').
by(values('factor_a')).
by(values('factor_b')).
by(map{ it.get().value('factor_a') * 
        it.get().value('factor_b') })

It is currently formatted like this:

a = 4.5;

b = 4.5;

g.V(ids).
  has('factor_a').
  has('factor_b').
  project('Factor A', 'Factor B', 'Product').
    by(values('factor_a')).
    by(values('factor_b')).
    by(map{ it.get().value('factor_a') * 
            it.get().value('factor_b') })

But it should be formatted like this:

a = 4.5;
b = 4.5;

g.V(ids).
  has('factor_a').
  has('factor_b').
  project('Factor A', 'Factor B', 'Product').
    by(values('factor_a')).
    by(values('factor_b')).
    by(map{ it.get().value('factor_a') * 
            it.get().value('factor_b') })

In other words, all non-Gremlin code should be left alone, which is essentially the same as https://github.com/OyvindSabo/gremlint/issues/67.