use of com.intellij.psi.impl.FreeThreadedFileViewProvider in project intellij-community by JetBrains.
the class SmartPsiElementPointerImpl method doCreateElementInfo.
@NotNull
private static <E extends PsiElement> SmartPointerElementInfo doCreateElementInfo(@NotNull Project project, @NotNull E element, PsiFile containingFile, boolean forInjected) {
if (element instanceof PsiDirectory) {
return new DirElementInfo((PsiDirectory) element);
}
if (element instanceof PsiCompiledElement || containingFile == null || !containingFile.isPhysical() || !element.isPhysical()) {
if (element instanceof StubBasedPsiElement && element instanceof PsiCompiledElement) {
if (element instanceof PsiFile) {
return new FileElementInfo((PsiFile) element);
}
PsiAnchor.StubIndexReference stubReference = PsiAnchor.createStubReference(element, containingFile);
if (stubReference != null) {
return new ClsElementInfo(stubReference);
}
}
return new HardElementInfo(project, element);
}
FileViewProvider viewProvider = containingFile.getViewProvider();
if (viewProvider instanceof FreeThreadedFileViewProvider) {
PsiLanguageInjectionHost hostContext = InjectedLanguageManager.getInstance(containingFile.getProject()).getInjectionHost(containingFile);
TextRange elementRange = element.getTextRange();
if (hostContext != null && elementRange != null) {
SmartPsiElementPointer<PsiLanguageInjectionHost> hostPointer = SmartPointerManager.getInstance(project).createSmartPsiElementPointer(hostContext);
return new InjectedSelfElementInfo(project, element, elementRange, containingFile, hostPointer);
}
}
SmartPointerElementInfo info = createAnchorInfo(element, containingFile);
if (info != null) {
return info;
}
if (element instanceof PsiFile) {
return new FileElementInfo((PsiFile) element);
}
TextRange elementRange = element.getTextRange();
if (elementRange == null) {
return new HardElementInfo(project, element);
}
if (elementRange.isEmpty() && PsiTreeUtil.findChildOfType(element, ForeignLeafPsiElement.class) != null) {
// restored by just one offset in a file, so hold it on a hard reference
return new HardElementInfo(project, element);
}
ProperTextRange proper = ProperTextRange.create(elementRange);
return new SelfElementInfo(project, proper, Identikit.fromPsi(element, LanguageUtil.getRootLanguage(element)), containingFile, forInjected);
}
use of com.intellij.psi.impl.FreeThreadedFileViewProvider in project intellij-community by JetBrains.
the class CompositeElement method isNonPhysicalOrInjected.
private boolean isNonPhysicalOrInjected() {
FileElement fileElement = TreeUtil.getFileElement(this);
if (fileElement == null || fileElement instanceof DummyHolderElement)
return true;
// dummy holder
if (fileElement.getTreeParent() != null)
return true;
PsiElement wrapper = this instanceof PsiElement ? (PsiElement) this : myWrapper;
if (wrapper == null)
return true;
PsiFile psiFile = wrapper.getContainingFile();
return psiFile == null || psiFile instanceof DummyHolder || psiFile.getViewProvider() instanceof FreeThreadedFileViewProvider || !psiFile.isPhysical();
}
Aggregations