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

Highlight the whole struct literal when unnamed element is present #2819

Open
wbars opened this issue Nov 3, 2016 · 1 comment · May be fixed by #2826
Open

Highlight the whole struct literal when unnamed element is present #2819

wbars opened this issue Nov 3, 2016 · 1 comment · May be fixed by #2826

Comments

@wbars
Copy link
Contributor

wbars commented Nov 3, 2016

I think that current logic of GoStructInitializationInspection could be better: inspection suggests to replace single unnamed element by named, but we have to name all element in the struct literal to get valid code.

So i propose highlight the whole struct literal when at least one unnamed element is present. Quickfix will add names to all unnamed elements.

P.S. Current implementation misses case when several fields in struct declared by one type (see image.Point) as example.

wbars added a commit to wbars/go-lang-idea-plugin that referenced this issue Nov 13, 2016
wbars added a commit to wbars/go-lang-idea-plugin that referenced this issue Nov 13, 2016
wbars added a commit to wbars/go-lang-idea-plugin that referenced this issue Nov 13, 2016
@wbars wbars linked a pull request Nov 13, 2016 that will close this issue
@wbars
Copy link
Contributor Author

wbars commented Nov 13, 2016

I made an outline of the reworked inspection to demonstrate the idea.

Main change is the object for highlighting - now it is the whole literal. Proposed logic is described above. I think that it will be more natural way of handling unnamed elements since we will not have to name all highlighted elements one by one to get valid code.

Also PR includes some missed cases for this inspection, like anonymous field definition, or several field definitions within one declaration.

wbars added a commit to wbars/go-lang-idea-plugin that referenced this issue Nov 13, 2016
wbars added a commit to wbars/go-lang-idea-plugin that referenced this issue Nov 13, 2016
wbars added a commit to wbars/go-lang-idea-plugin that referenced this issue Nov 13, 2016
wbars added a commit to wbars/go-lang-idea-plugin that referenced this issue Nov 14, 2016
wbars added a commit to wbars/go-lang-idea-plugin that referenced this issue Nov 14, 2016
wbars added a commit to wbars/go-lang-idea-plugin that referenced this issue Nov 14, 2016
wbars added a commit to wbars/go-lang-idea-plugin that referenced this issue Nov 15, 2016
wbars added a commit to wbars/go-lang-idea-plugin that referenced this issue Nov 16, 2016
wbars added a commit to wbars/go-lang-idea-plugin that referenced this issue Dec 8, 2016
wbars added a commit to wbars/go-lang-idea-plugin that referenced this issue Dec 8, 2016
wbars added a commit to wbars/go-lang-idea-plugin that referenced this issue Dec 8, 2016
wbars added a commit to wbars/go-lang-idea-plugin that referenced this issue Dec 9, 2016
wbars added a commit to wbars/go-lang-idea-plugin that referenced this issue Dec 13, 2016
wbars added a commit to wbars/go-lang-idea-plugin that referenced this issue Dec 13, 2016
wbars added a commit to wbars/go-lang-idea-plugin that referenced this issue Dec 14, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant