mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[maven] IDEA-288023 optimize DomGotoSuperHandler
GitOrigin-RevId: c4dd791af618e928494a78f881d60fa04c1b7356
This commit is contained in:
committed by
intellij-monorepo-bot
parent
9c66641799
commit
a74af24011
@@ -5,13 +5,12 @@ import com.intellij.codeInsight.CodeInsightActionHandler;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.xml.DomElement;
|
||||
import com.intellij.util.xml.DomElementNavigationProvider;
|
||||
import com.intellij.util.xml.DomUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class DomGotoSuperHandler implements CodeInsightActionHandler {
|
||||
@Override
|
||||
public void invoke(@NotNull Project project,
|
||||
@@ -19,18 +18,18 @@ public class DomGotoSuperHandler implements CodeInsightActionHandler {
|
||||
@NotNull PsiFile file) {
|
||||
|
||||
var currentElement = DomUtil.getDomElement(editor, file);
|
||||
if (currentElement == null) {
|
||||
return;
|
||||
while (currentElement != null) {
|
||||
DomElementNavigationProvider provider = getDomElementNavigationProvider(currentElement);
|
||||
if (provider != null) {
|
||||
provider.navigate(currentElement, true);
|
||||
return;
|
||||
} else {
|
||||
currentElement = currentElement.getParent();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Stream.iterate(currentElement, Objects::nonNull, DomElement::getParent)
|
||||
.flatMap(element -> {
|
||||
return DomGotoActions.DOM_GOTO_SUPER.getExtensionList()
|
||||
.stream()
|
||||
.filter(p -> p.canNavigate(element))
|
||||
.<Runnable>map(p -> () -> p.navigate(element, true));
|
||||
})
|
||||
.findFirst()
|
||||
.ifPresent(Runnable::run);
|
||||
private static DomElementNavigationProvider getDomElementNavigationProvider(DomElement element) {
|
||||
return ContainerUtil.find(DomGotoActions.DOM_GOTO_SUPER.getExtensionList(), p -> p.canNavigate(element));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user