SelfElementInfo( @NotNull Project project, @Nullable ProperTextRange range, @NotNull AnchorTypeInfo info, @NotNull PsiFile containingFile, boolean forInjected) { myForInjected = forInjected; myType = info; myManager = (SmartPointerManagerImpl) SmartPointerManager.getInstance(project); myMarkerCache = myManager.getMarkerCache(containingFile.getViewProvider().getVirtualFile()); setRange(range); myMarkerCache.rangeChanged(); }
@Override @Nullable public Segment getRange() { if (hasRange()) { Document document = getDocumentToSynchronize(); if (document != null) { PsiDocumentManagerBase documentManager = myManager.getPsiDocumentManager(); List<DocumentEvent> events = documentManager.getEventsSinceCommit(document); if (!events.isEmpty()) { return myMarkerCache.getUpdatedRange( this, (FrozenDocument) documentManager.getLastCommittedDocument(document), events); } } } return calcPsiRange(); }
@Override @NotNull public final VirtualFile getVirtualFile() { return myMarkerCache.getVirtualFile(); }