mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
EA-20711
This commit is contained in:
+3
-2
@@ -19,6 +19,7 @@ import com.intellij.injected.editor.DocumentWindow;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* User: cdr
|
||||
@@ -26,8 +27,8 @@ import com.intellij.psi.PsiElement;
|
||||
class InjectedSelfElementInfo extends SelfElementInfo {
|
||||
private DocumentWindow myDocument;
|
||||
|
||||
InjectedSelfElementInfo(PsiElement anchor) {
|
||||
super(anchor);
|
||||
InjectedSelfElementInfo(@NotNull PsiElement anchor, @NotNull Document document) {
|
||||
super(anchor, document);
|
||||
|
||||
assert myFile.getContext() != null;
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ class SelfElementInfo implements SmartPointerElementInfo {
|
||||
private Class myType;
|
||||
private final Project myProject;
|
||||
|
||||
public SelfElementInfo(PsiElement anchor) {
|
||||
public SelfElementInfo(@NotNull PsiElement anchor, @NotNull Document document) {
|
||||
LOG.assertTrue(anchor.isPhysical());
|
||||
myFile = anchor.getContainingFile();
|
||||
TextRange range = anchor.getTextRange();
|
||||
@@ -49,9 +49,7 @@ class SelfElementInfo implements SmartPointerElementInfo {
|
||||
|
||||
myProject = myFile.getProject();
|
||||
final PsiDocumentManager documentManager = PsiDocumentManager.getInstance(myProject);
|
||||
Document document = documentManager.getDocument(myFile);
|
||||
|
||||
LOG.assertTrue(document != null, myFile.getName());
|
||||
if (documentManager.isUncommited(document)) {
|
||||
mySyncMarkerIsValid = false;
|
||||
myMarker = document.createRangeMarker(0, 0, false);
|
||||
|
||||
+12
-2
@@ -125,8 +125,18 @@ class SmartPsiElementPointerImpl<E extends PsiElement> implements SmartPointerEx
|
||||
}
|
||||
}
|
||||
|
||||
return containingFile.getContext() != null ? new InjectedSelfElementInfo(myElement) :
|
||||
myElement instanceof PsiFile ? new FileElementInfo((PsiFile)myElement) : new SelfElementInfo(myElement);
|
||||
if (myElement instanceof PsiFile) {
|
||||
return new FileElementInfo((PsiFile)myElement);
|
||||
}
|
||||
PsiDocumentManager documentManager = PsiDocumentManager.getInstance(getProject());
|
||||
Document document = documentManager.getDocument(containingFile);
|
||||
if (document == null) return null; // must be non-text file
|
||||
|
||||
if (containingFile.getContext() != null) {
|
||||
return new InjectedSelfElementInfo(myElement, document);
|
||||
}
|
||||
|
||||
return new SelfElementInfo(myElement, document);
|
||||
}
|
||||
|
||||
private static boolean areElementKindEqual(PsiElement element1, PsiElement element2) {
|
||||
|
||||
Reference in New Issue
Block a user