mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
more IDEA-CR-1432
This commit is contained in:
@@ -46,7 +46,7 @@ public class JavaAnchorProvider extends SmartPointerAnchorProvider {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public PsiElement getElement(@NotNull PsiElement anchor) {
|
||||
public PsiElement restoreElement(@NotNull PsiElement anchor) {
|
||||
if (anchor instanceof PsiIdentifier) {
|
||||
PsiElement parent = anchor.getParent();
|
||||
if (parent instanceof PsiJavaCodeReferenceElement) { // anonymous class, type
|
||||
|
||||
@@ -73,7 +73,7 @@ class AnchorElementInfo extends SelfElementInfo {
|
||||
if (range.getStartOffset() != getSyncStartOffset() || range.getEndOffset() != getSyncEndOffset()) return null;
|
||||
|
||||
for (SmartPointerAnchorProvider provider : SmartPointerAnchorProvider.EP_NAME.getExtensions()) {
|
||||
final PsiElement element = provider.getElement(anchor);
|
||||
final PsiElement element = provider.restoreElement(anchor);
|
||||
if (element != null) return element;
|
||||
}
|
||||
return null;
|
||||
|
||||
+1
-2
@@ -58,9 +58,8 @@ public class AnchorElementInfoFactory implements SmartPointerElementInfoFactory
|
||||
PsiElement anchor = null;
|
||||
for (SmartPointerAnchorProvider provider : SmartPointerAnchorProvider.EP_NAME.getExtensions()) {
|
||||
anchor = provider.getAnchor(element);
|
||||
if (anchor != null) break;
|
||||
if (anchor != null && anchor.isPhysical()) return anchor;
|
||||
}
|
||||
if (anchor != null && (!anchor.isPhysical() /*|| anchor.getTextRange()==null*/)) return null;
|
||||
return anchor;
|
||||
}
|
||||
}
|
||||
|
||||
+4
-2
@@ -29,8 +29,10 @@ public abstract class SmartPointerAnchorProvider {
|
||||
public static final ExtensionPointName<SmartPointerAnchorProvider> EP_NAME = ExtensionPointName.create("com.intellij.smartPointer.anchorProvider");
|
||||
|
||||
/**
|
||||
* Provides anchor used for restoring elements after stub-to-AST switch.
|
||||
* One can use name identifier (such as tag or method name) as an anchor
|
||||
* @param element
|
||||
* @return anchor to be used when restoring element after stub-to-AST switch
|
||||
* @return anchor to be used when restoring element
|
||||
*/
|
||||
@Nullable
|
||||
public abstract PsiElement getAnchor(@NotNull PsiElement element);
|
||||
@@ -40,5 +42,5 @@ public abstract class SmartPointerAnchorProvider {
|
||||
* @return restored original element using anchor
|
||||
*/
|
||||
@Nullable
|
||||
public abstract PsiElement getElement(@NotNull PsiElement anchor);
|
||||
public abstract PsiElement restoreElement(@NotNull PsiElement anchor);
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ public class XmlAnchorProvider extends SmartPointerAnchorProvider {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public PsiElement getElement(@NotNull PsiElement anchor) {
|
||||
public PsiElement restoreElement(@NotNull PsiElement anchor) {
|
||||
if (anchor instanceof XmlToken) {
|
||||
XmlToken token = (XmlToken)anchor;
|
||||
return token.getTokenType() == XmlTokenType.XML_NAME ? token.getParent() : null;
|
||||
|
||||
Reference in New Issue
Block a user