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

Find references to fields via getters/setters #1548

Closed
Frederick888 opened this issue Sep 16, 2020 · 12 comments · Fixed by #1561 or #1568
Closed

Find references to fields via getters/setters #1548

Frederick888 opened this issue Sep 16, 2020 · 12 comments · Fixed by #1561 or #1568

Comments

@Frederick888
Copy link

I'm using coc-java with jdt.ls v0.60.0.

Currently <Plug>(coc-references) only returns direct usages for class fields. To list references via getters/setters, one has to do coc-references on those methods again. This can be even more inconvenient when Lombok is used, in which case coc only says [coc.nvim] References not found (I have configured VM options correctly I think, as I can see getter/setter completions).

@fbricon
Copy link
Contributor

fbricon commented Sep 18, 2020

I don't think Eclipse JDT supports that. @snjeza can you check please?

@Frederick888
Copy link
Author

Sorry I may have not made it clear but this is a feature request :)

@snjeza
Copy link
Contributor

snjeza commented Sep 19, 2020

Java LS supports Find References. Eclipse supports All Occurrences, References, Declarations, Read Accesses, Write Accesses
eclipsesearch
@fbricon We can implement some of these features.

@snjeza
Copy link
Contributor

snjeza commented Sep 19, 2020

@Frederick888 You can check <Plug>(coc-definition).

@Frederick888
Copy link
Author

@snjeza I'm a little lost. <Plug>(coc-definition) is used to find the definition of classes/fields/etc I think? For instance,

@Entity
@Data
@NoArgsConstructor
@AllArgsConstructor(access = AccessLevel.PRIVATE)
@EqualsAndHashCode(exclude = {"apples"})
public class Tree {
    @Id
    @GeneratedValue
    private Long id;

    @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, mappedBy = "tree")
    private List<Apple> apples;
}

I can use <Plug>(coc-definition) on tree.getApples() atm, which takes me to @Data above; but what I'd like to do here is to use <Plug>(coc-references) on private List<Apple> apples to find all the getApples() calls.

@snjeza
Copy link
Contributor

snjeza commented Sep 20, 2020

@Frederick888 can you provide a project example?

@snjeza
Copy link
Contributor

snjeza commented Sep 21, 2020

I can can try to add getter/setter references when searching field references.
@fbricon what do you think?

@fbricon
Copy link
Contributor

fbricon commented Sep 21, 2020

yes, but we should make it optional. Add a pref to disable it please.

@snjeza
Copy link
Contributor

snjeza commented Sep 21, 2020

@fbricon ok.

@Frederick888
Copy link
Author

@snjeza Thank you!

And by the way -- I know I'm probably asking for too much here -- will it also be possible to jump from fields to Lombok constructors/builders? For instance, from https://github.com/Frederick888/java-dummy/blob/b38bab6e135e84dc5d181294d719e06e77b4a16e/src/main/java/com/example/demo/dao/Apple.java#L24 to https://github.com/Frederick888/java-dummy/blob/master/src/main/java/com/example/demo/service/impl/AppleTreeServiceImpl.java#L26 ?

@snjeza
Copy link
Contributor

snjeza commented Sep 23, 2020

@Frederick888 I will try.

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