mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
(no message)
This commit is contained in:
@@ -6,8 +6,9 @@ package com.intellij.psi.jsp;
|
||||
|
||||
import com.intellij.psi.ImplicitVariable;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.pom.Navigatable;
|
||||
|
||||
public interface JspImplicitVariable extends JspElement, ImplicitVariable{
|
||||
public interface JspImplicitVariable extends JspElement, ImplicitVariable, Navigatable {
|
||||
JspImplicitVariable[] EMPTY_ARRAY = new JspImplicitVariable[0];
|
||||
int INSIDE = 1;
|
||||
int AFTER = 2;
|
||||
|
||||
@@ -9,15 +9,10 @@ import com.intellij.ide.util.EditSourceUtil;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.LogicalPosition;
|
||||
import com.intellij.openapi.fileEditor.FileEditorManager;
|
||||
import com.intellij.openapi.fileEditor.OpenFileDescriptor;
|
||||
import com.intellij.openapi.fileTypes.FileTypeSupportCapabilities;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.pom.Navigatable;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.jsp.JspAction;
|
||||
import com.intellij.psi.jsp.JspAttribute;
|
||||
import com.intellij.psi.jsp.JspImplicitVariable;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.util.PsiSuperMethodUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
@@ -60,12 +55,6 @@ public class GotoDeclarationAction extends BaseCodeInsightAction implements Code
|
||||
return;
|
||||
}
|
||||
|
||||
if (element instanceof JspImplicitVariable) {
|
||||
final JspImplicitVariable variable = (JspImplicitVariable) element;
|
||||
element = variable.getDeclaration();
|
||||
}
|
||||
if (element == null) return;
|
||||
|
||||
FeatureUsageTracker.getInstance().triggerFeatureUsed("navigation.goto.declaration");
|
||||
PsiElement navElement = element.getNavigationElement();
|
||||
|
||||
@@ -79,11 +68,9 @@ public class GotoDeclarationAction extends BaseCodeInsightAction implements Code
|
||||
}
|
||||
}
|
||||
|
||||
PsiFile targetFile = navElement.getContainingFile();
|
||||
// Fix for floating declarations such as array class, jsp taglib etc.
|
||||
if (targetFile == null || targetFile.getVirtualFile() == null) return;
|
||||
OpenFileDescriptor descriptor = new OpenFileDescriptor(project, targetFile.getVirtualFile(), navElement.getTextOffset());
|
||||
FileEditorManager.getInstance(project).openTextEditor(descriptor, true);
|
||||
if (navElement instanceof Navigatable) {
|
||||
((Navigatable)navElement).navigate(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -152,45 +139,6 @@ public class GotoDeclarationAction extends BaseCodeInsightAction implements Code
|
||||
return editor.getCaretModel().getOffset();
|
||||
}
|
||||
|
||||
private PsiElement findDeclarationAction(PsiElement place, JspImplicitVariable variable) {
|
||||
if (place == null) return null;
|
||||
|
||||
if (place instanceof JspAction) {
|
||||
JspAction action = (JspAction) place;
|
||||
|
||||
final JspAttribute[] attributes = action.getAttributes();
|
||||
|
||||
for (int i = 0; i < attributes.length; i++) {
|
||||
JspAttribute attribute = attributes[i];
|
||||
final PsiElement valueElement = attribute.getValueElement();
|
||||
if (valueElement == null) continue;
|
||||
final PsiReference reference = valueElement.getReference();
|
||||
if (reference != null && reference.resolve() == variable) return attribute.getValueElement();
|
||||
}
|
||||
|
||||
JspImplicitVariable[] variables = action.getDeclaredVariables();
|
||||
|
||||
if (variables != null) {
|
||||
for (int i = 0; i < variables.length; i++) {
|
||||
JspImplicitVariable v = variables[i];
|
||||
|
||||
if (v == variable) {
|
||||
return action;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PsiElement[] children = place.getChildren();
|
||||
for (int i = 0; i < children.length; i++) {
|
||||
PsiElement child = children[i];
|
||||
PsiElement action = findDeclarationAction(child, variable);
|
||||
if (action != null) return action;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static PsiElement findTargetElement(Project project, Editor editor, int offset) {
|
||||
int flags = TargetElementUtil.REFERENCED_ELEMENT_ACCEPTED
|
||||
| TargetElementUtil.NEW_AS_CONSTRUCTOR
|
||||
|
||||
Reference in New Issue
Block a user