Coder Social home page Coder Social logo

Comments (19)

mduft avatar mduft commented on June 9, 2024 1

Hey,

Thanks for the analysis! I can certainly test this, yes :) It will just take me a little time to do so...

Cheers,
Markus

from lcdsl.

mduft avatar mduft commented on June 9, 2024 1

New build is available at https://mduft.github.io/lcdsl-latest/ - you can verify (and hopefully enjoy) your changes there :)

from lcdsl.

miklossy avatar miklossy commented on June 9, 2024

Such a result usually comes if the Xtext default formatter is used, but in LcDsl, a custom formatter implementation is already bound in the AbstractLcDslRuntimeModule, so I think this issue has been solved in the meantime and can be closed.

from lcdsl.

mduft avatar mduft commented on June 9, 2024

Yes, a formatter is bound and in place. However it does not fully work, and I haven't had time to look into the issue. It seems that indentation is only correctly applied for the first line of a block, but not for the others...

from lcdsl.

miklossy avatar miklossy commented on June 9, 2024

Thanks for the info. You are right, I experienced the same behaviour. I will take a look at it and try to provide a pull request to improve the formatter.

from lcdsl.

mduft avatar mduft commented on June 9, 2024

This would be really appreciated, thanks!

from lcdsl.

miklossy avatar miklossy commented on June 9, 2024

Hi Markus,

I analysed the problem and found out that in order to make the indentation properly work, the formatter should append a newline to each line. A quick solution could be to override the void format(EObject it, extension IFormattableDocument document) method in the LcDslFormatter class:

class LcDslFormatter extends AbstractFormatter2 {
    ...
    override dispatch void format(EObject it, extension IFormattableDocument document) {
        regionForEObject.allSemanticRegions.last.append[newLine]
    }
}

However, it could result in some unwanted side-effects when applying this customization to all EObjects. Do you have the possibility to test it on some *.lc files?

Thanks a lot for you feedback!
Tamás

from lcdsl.

mduft avatar mduft commented on June 9, 2024

I tried this out quickly, and it seems that once I remove indentation on any line within a launch configuration, format will not bring it back :| It seems this kind of override is also never called, since the other dispatch methods in the file get precedence when they match - at least a Syserr in the method was never called.

from lcdsl.

miklossy avatar miklossy commented on June 9, 2024

Hmm.. interesting. Actually it seems to work on my computer:
screencast

from lcdsl.

miklossy avatar miklossy commented on June 9, 2024

@mduft Could it be possible that your code base is different from that what is checked in in the master branch? https://github.com/mduft/lcdsl/blob/master/com.wamas.ide.launching/src/com/wamas/ide/launching/formatting2/LcDslFormatter.xtend

from lcdsl.

mduft avatar mduft commented on June 9, 2024

Nope, I just freshly cloned, maybe something else went wrong... You just added that method as it is shown at the end of the file, right? Because that's what I tried :D

from lcdsl.

mduft avatar mduft commented on June 9, 2024

Ah, I think I found it - will re-test :) There was a problem with my setup.

from lcdsl.

mduft avatar mduft commented on June 9, 2024

OK, now it works. The only problem I observed when formatting our lc files is that blank lines disappear... We have a lot of blank lines separating blocks of arguments belonging together, blank lines before comments, etc.

from lcdsl.

miklossy avatar miklossy commented on June 9, 2024

Preserving the already present new lines can be controlled by the setNewLines(int minNewLines, int defaultNewLines, int maxNewLines) parameters.

	/**
	 * Configures the given new lines for this hidden region. Keeps the current configuration if it is in the valid
	 * boundaries of {@code minNewLines} and {@code maxNewLines}. Applies {@code defaultNewLines} otherwise.
	 */
	void setNewLines(int minNewLines, int defaultNewLines, int maxNewLines);

Instead of calling regionForEObject.allSemanticRegions.last.append[newLine], you can call e.g.
regionForEObject.allSemanticRegions.last.append[setNewLines(1,1,2)]
screencast
Hint: In order to avoid org.eclipse.xtext.formatting2.ConflictingFormattingException: Conflicting values, you may have to adapt the [newline] parameters on other places as well.

from lcdsl.

mduft avatar mduft commented on June 9, 2024

Nice, thanks :) Can you provide a pull request? I would otherwise try to squeeze the changes in somewhere in the next days...

from lcdsl.

miklossy avatar miklossy commented on June 9, 2024

Yes, I will provide a PR soon.

from lcdsl.

mduft avatar mduft commented on June 9, 2024

This is great news, thanks :)

from lcdsl.

miklossy avatar miklossy commented on June 9, 2024

I created the PR

from lcdsl.

mduft avatar mduft commented on June 9, 2024

Thanks a lot. Will release ASAP.

from lcdsl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.