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

Some inconsistencies in default style #586

Closed
RblSb opened this issue Apr 23, 2020 · 6 comments
Closed

Some inconsistencies in default style #586

RblSb opened this issue Apr 23, 2020 · 6 comments
Labels
bug Something isn't working tokentree requires fix in tokentree whitespace missing or incorrect space around token

Comments

@RblSb
Copy link
Contributor

RblSb commented Apr 23, 2020

Formatted output:

typedef Type = {f:Int}
typedef Type = {f:{f:Int}}

class Main {
	function foo():Void {
		final test:Void->Void = () -> trace(1);
		final test:() -> Void = () -> trace(1);
		final obj:{f: Int} = {f: 1};
		final obj:{f: {f: Int}} = {f: {f: 1}};
		final int:Int = 1;
	}
}

I think () -> Void and {f: Int} can be without spaces by default, so it would be easier to distinguish type vs value stuff?

@Gama11
Copy link
Member

Gama11 commented Apr 23, 2020

{f: Int} is a bug, possibly caused by using final instead of var. Spaces around -> for arrow functions and Haxe 4 style function types are working as intended.

@AlexHaxe AlexHaxe added bug Something isn't working tokentree requires fix in tokentree whitespace missing or incorrect space around token labels Apr 23, 2020
AlexHaxe added a commit to AlexHaxe/haxe-formatter that referenced this issue Apr 24, 2020
@AlexHaxe
Copy link
Member

@RblSb
Copy link
Contributor Author

RblSb commented Apr 24, 2020

Thanks. Is there is a setting to support var:()->Void = () -> 1; style option? (separated whitespace policy for arrow function type hint)

@AlexHaxe
Copy link
Member

{
  "whitespace": {
    "arrowFunctionsPolicy": "around",
    "functionTypeHaxe3Policy": "none",
    "functionTypeHaxe4Policy": "none"
  }
}

you can play around with these options here https://haxecheckstyle.github.io/haxe-formatter-docs/#codesamples.WhitespaceSamples.function_types_and_arrows

You can edit code area and hxformat.json on these pages, so you can safely test different code styles with your own code snippets and or formatter configuration.

@RblSb
Copy link
Contributor Author

RblSb commented Apr 24, 2020

Thanks again, sorry for carelessness in testing!

@AlexHaxe
Copy link
Member

no problem, the documentation pages are quite new and far from complete.
Also it's not always clear what is intentional and what is a bug, or which setting corresponds to what behaviour.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working tokentree requires fix in tokentree whitespace missing or incorrect space around token
Projects
None yet
Development

No branches or pull requests

3 participants