Is there an api method to set the navigation marker based on the file line number?

Answered

Is there an api method to set the navigation marker based on the file line number?
Instead of implementing RelatedItemLineMarkerProvider to set the marker.

As shown in the figure, I want to set a navigation marker for the nth row

 
0
4 comments

Hi,

What is your exact use case (please always provide it)? Are the icons you want to add related to elements in any way?

0

I'm working on a navigation marker, but it seems to be scanned multiple times.

I'm not sure if the restrictions I made are working. As shown in the picture

So I would like to ask if there is a simpler api to do this task.

0

It is still unclear to me.

It seems you add markers twice for the same element (probably getApiElement(element) returns duplicates - why?), so please focus on investigating why it happens and not on trying to implement an alternative hacky solution.

0

Thank you very much.

I think I have found the solution, here is the new modified code. The comments are from the previous code

   public List<Dto> getApiElement(@NotNull PsiElement element) {

ArrayList<Dto> v = new ArrayList<>();
if (element instanceof GoStatement){
String text = element.getText();
if (MatchEnum.group(text)) {
group = Search.getAllRequestPath(text);
}
if ( group != null && MatchEnum.request(text)) {
String path = Search.getAllRequestPath(text);
Dto dto = new Dto();
GotoModel model = new GotoModel();
model.setPath(group+path);
model.setRequestEnum(MatchEnum.requestType(text));
dto.setPsiElement(element);
dto.setGotoModel(model);
v.add(dto);
}
}

// if (!JbLanguageUtil.isLanguage(element, GoLanguage.INSTANCE)) {
// return null;
// }
// final String[] group = {null};
// element.accept(new GoRecursiveVisitor() { //有多种方法!
// @Override
// public void visitStatement(@NotNull GoStatement o) {
// String text = o.getText();
// if (MatchEnum.group(text)) {
// group[0] = Search.getAllRequestPath(text);
// }
// if ( group[0] != null && MatchEnum.request(text)) {
// String path = Search.getAllRequestPath(text);
// Dto dto = new Dto();
// GotoModel model = new GotoModel();
// model.setPath(group[0]+path);
// model.setRequestEnum(MatchEnum.requestType(text));
// dto.setPsiElement(o);
// dto.setGotoModel(model);
// v.add(dto);
// }
// }
// });
return v;
}
 
 
0

Please sign in to leave a comment.