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

Formatter for IDL and Xtend #113

Closed
dlime opened this issue May 23, 2017 · 3 comments
Closed

Formatter for IDL and Xtend #113

dlime opened this issue May 23, 2017 · 3 comments

Comments

@dlime
Copy link

dlime commented May 23, 2017

Hello! I'm facing this issue:
I have many IDL and Xtend files that I would like to include to the spotless auto formatter task.
I'm planning to define a custom XML file, similar to the Eclipse ones, in order to give formatting rules.

For now the only thing that I can do is this:

format 'IDL', {
    target '**/*.idl'
    trimTrailingWhitespace()
    endWithNewline()
}

I'm looking forward to do this:

format 'IDL', {
    target '**/*.idl'
    eclipse().configFile 'spotless.eclipseformat.xml'
    trimTrailingWhitespace()
    endWithNewline()
}

Right now this will throw the following error:

Could not find method eclipse() for arguments [] on object of type com.diffplug.gradle.spotless.FormatExtension.

Any ideas or suggestions for formatting non Java files with a custom XML file?

@nedtwigg
Copy link
Member

format 'language' only has generic formatters.

Language-specific formatters are only available in language-specific blocks, java {, groovy {, scala {, etc.

to fix your example, you could do:

java {
    target '**/*.idl'
    eclipse().configFile 'spotless.eclipseformat.xml'
}

But I'd be very surprised if the standard eclipse code formatter from JDT can also format xtend and IDL.

I think you'll probably need to create a new FormatterStep. You can do so in a separate project or in your buildscript, and we'd love a PR which includes your new features:

https://github.com/diffplug/spotless/blob/master/CONTRIBUTING.md

@dlime
Copy link
Author

dlime commented May 24, 2017

Thanks for suggestion! I was thinking to create my own XML file for formatting IDL/Xtend (I saw that I can define it with Checkstyle and then converting it to Eclipse)
I'll keep you updated:)

@nedtwigg nedtwigg changed the title How to use an Eclipse XML for non standard file extensions? Formatter for IDL and Xtend Jun 20, 2017
@nedtwigg
Copy link
Member

Closing due to inactivity, happy to reopen.

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

No branches or pull requests

2 participants