com.intellij.psi.impl.source.PsiFileImpl Java Examples
The following examples show how to use
com.intellij.psi.impl.source.PsiFileImpl.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SoyFileViewProvider.java From bamboo-soy with Apache License 2.0 | 6 votes |
@Override protected PsiFile createFile(@NotNull Language lang) { ParserDefinition parserDefinition = getDefinition(lang); if (parserDefinition == null) { return null; } if (lang.is(TEMPLATE_DATA_LANGUAGE)) { PsiFileImpl file = (PsiFileImpl) parserDefinition.createFile(this); file.setContentElementType(TEMPLATE_DATA_ELEMENT_TYPE); return file; } else if (lang.isKindOf(BASE_LANGUAGE)) { return parserDefinition.createFile(this); } else { return null; } }
Example #2
Source File: StubTreeBuilder.java From consulo with Apache License 2.0 | 6 votes |
/** * Order is deterministic. First element matches {@link FileViewProvider#getStubBindingRoot()} */ @Nonnull public static List<Pair<IStubFileElementType, PsiFile>> getStubbedRoots(@Nonnull FileViewProvider viewProvider) { final List<Trinity<Language, IStubFileElementType, PsiFile>> roots = new SmartList<>(); final PsiFile stubBindingRoot = viewProvider.getStubBindingRoot(); for (Language language : viewProvider.getLanguages()) { final PsiFile file = viewProvider.getPsi(language); if (file instanceof PsiFileImpl) { final IElementType type = ((PsiFileImpl)file).getElementTypeForStubBuilder(); if (type != null) { roots.add(Trinity.create(language, (IStubFileElementType)type, file)); } } } ContainerUtil.sort(roots, (o1, o2) -> { if (o1.third == stubBindingRoot) return o2.third == stubBindingRoot ? 0 : -1; else if (o2.third == stubBindingRoot) return 1; else return StringUtil.compare(o1.first.getID(), o2.first.getID(), false); }); return ContainerUtil.map(roots, trinity -> Pair.create(trinity.second, trinity.third)); }
Example #3
Source File: PsiDocumentManagerBase.java From consulo with Apache License 2.0 | 6 votes |
@SuppressWarnings("AssignmentToStaticFieldFromInstanceMethod") public void reparseFileFromText(@Nonnull PsiFileImpl file) { ApplicationManager.getApplication().assertIsDispatchThread(); if (isCommitInProgress()) throw new IllegalStateException("Re-entrant commit is not allowed"); FileElement node = file.calcTreeElement(); CharSequence text = node.getChars(); ourIsFullReparseInProgress = true; try { WriteAction.run(() -> { ProgressIndicator indicator = ProgressIndicatorProvider.getGlobalProgressIndicator(); if (indicator == null) indicator = new EmptyProgressIndicator(); DiffLog log = BlockSupportImpl.makeFullParse(file, node, text, indicator, text).log; log.doActualPsiChange(file); file.getViewProvider().contentsSynchronized(); }); } finally { ourIsFullReparseInProgress = false; } }
Example #4
Source File: BlockSupportImpl.java From consulo with Apache License 2.0 | 6 votes |
@Nonnull static ReparseResult reparse(@Nonnull final PsiFile file, @Nonnull FileASTNode oldFileNode, @Nonnull TextRange changedPsiRange, @Nonnull final CharSequence newFileText, @Nonnull final ProgressIndicator indicator, @Nonnull CharSequence lastCommittedText) { PsiFileImpl fileImpl = (PsiFileImpl)file; final Couple<ASTNode> reparseableRoots = findReparseableRoots(fileImpl, oldFileNode, changedPsiRange, newFileText); if (reparseableRoots == null) { return makeFullParse(fileImpl, oldFileNode, newFileText, indicator, lastCommittedText); } ASTNode oldRoot = reparseableRoots.first; ASTNode newRoot = reparseableRoots.second; DiffLog diffLog = mergeTrees(fileImpl, oldRoot, newRoot, indicator, lastCommittedText); return new ReparseResult(diffLog, oldRoot, newRoot); }
Example #5
Source File: BlockSupportImpl.java From consulo with Apache License 2.0 | 6 votes |
private static boolean isReplaceWholeNode(@Nonnull PsiFileImpl fileImpl, @Nonnull ASTNode newRoot) throws ReparsedSuccessfullyException { final Boolean data = fileImpl.getUserData(DO_NOT_REPARSE_INCREMENTALLY); if (data != null) fileImpl.putUserData(DO_NOT_REPARSE_INCREMENTALLY, null); boolean explicitlyMarkedDeep = Boolean.TRUE.equals(data); if (explicitlyMarkedDeep || isTooDeep(fileImpl)) { return true; } final ASTNode childNode = newRoot.getFirstChildNode(); // maybe reparsed in PsiBuilderImpl and have thrown exception here boolean childTooDeep = isTooDeep(childNode); if (childTooDeep) { childNode.putUserData(TREE_DEPTH_LIMIT_EXCEEDED, null); fileImpl.putUserData(TREE_DEPTH_LIMIT_EXCEEDED, Boolean.TRUE); } return childTooDeep; }
Example #6
Source File: SmartPsiElementPointerImpl.java From consulo with Apache License 2.0 | 6 votes |
@Nullable private static SmartPointerElementInfo createAnchorInfo(@Nonnull PsiElement element, @Nonnull PsiFile containingFile) { if (element instanceof StubBasedPsiElement && containingFile instanceof PsiFileImpl) { IStubFileElementType stubType = ((PsiFileImpl)containingFile).getElementTypeForStubBuilder(); if (stubType != null && stubType.shouldBuildStubFor(containingFile.getViewProvider().getVirtualFile())) { StubBasedPsiElement stubPsi = (StubBasedPsiElement)element; int stubId = PsiAnchor.calcStubIndex(stubPsi); if (stubId != -1) { return new AnchorElementInfo(element, (PsiFileImpl)containingFile, stubId, stubPsi.getElementType()); } } } Pair<Identikit.ByAnchor, PsiElement> pair = Identikit.withAnchor(element, LanguageUtil.getRootLanguage(containingFile)); if (pair != null) { return new AnchorElementInfo(pair.second, containingFile, pair.first); } return null; }
Example #7
Source File: FileElement.java From consulo with Apache License 2.0 | 6 votes |
@Nonnull public final AstSpine getStubbedSpine() { AstSpine result = myStubbedSpine; if (result == null) { PsiFileImpl file = (PsiFileImpl)getPsi(); IStubFileElementType type = file.getElementTypeForStubBuilder(); if (type == null) return AstSpine.EMPTY_SPINE; result = RecursionManager.doPreventingRecursion(file, false, () -> new AstSpine(calcStubbedDescendants(type.getBuilder()))); if (result == null) { throw new StackOverflowPreventedException("Endless recursion prevented"); } myStubbedSpine = result; } return result; }
Example #8
Source File: MultiplePsiFilesPerDocumentFileViewProvider.java From consulo with Apache License 2.0 | 6 votes |
@Override protected PsiFile getPsiInner(@Nonnull final Language target) { PsiFileImpl file = myRoots.get(target); if (file == null) { if (!shouldCreatePsi()) return null; if (target != getBaseLanguage() && !getLanguages().contains(target)) { return null; } file = createPsiFileImpl(target); if (file == null) return null; if (myOriginal != null) { final PsiFile originalFile = myOriginal.getPsi(target); if (originalFile != null) { file.setOriginalFile(originalFile); } } file = ConcurrencyUtil.cacheOrGet(myRoots, target, file); } return file; }
Example #9
Source File: StubBasedPsiElementBase.java From consulo with Apache License 2.0 | 6 votes |
private ASTNode failedToBindStubToAst(@Nonnull PsiFileImpl file, @Nonnull final FileElement fileElement) { VirtualFile vFile = file.getVirtualFile(); StubTree stubTree = file.getStubTree(); final String stubString = stubTree != null ? ((PsiFileStubImpl)stubTree.getRoot()).printTree() : null; final String astString = RecursionManager.doPreventingRecursion("failedToBindStubToAst", true, () -> DebugUtil.treeToString(fileElement, true)); @NonNls final String message = "Failed to bind stub to AST for element " + getClass() + " in " + (vFile == null ? "<unknown file>" : vFile.getPath()) + "\nFile:\n" + file + "@" + System.identityHashCode(file); final String creationTraces = ourTraceStubAstBinding ? dumpCreationTraces(fileElement) : null; List<Attachment> attachments = new ArrayList<>(); if (stubString != null) { attachments.add(new Attachment("stubTree.txt", stubString)); } if (astString != null) { attachments.add(new Attachment("ast.txt", astString)); } if (creationTraces != null) { attachments.add(new Attachment("creationTraces.txt", creationTraces)); } throw new RuntimeExceptionWithAttachments(message, attachments.toArray(Attachment.EMPTY_ARRAY)); }
Example #10
Source File: StubBasedPsiElementBase.java From consulo with Apache License 2.0 | 6 votes |
/** * Ensures this element is AST-based. This is an expensive operation that might take significant time and allocate lots of objects, * so it should be to be avoided if possible. * * @return an AST node corresponding to this element. If the element is currently operating via stubs, * this causes AST to be loaded for the whole file and all stub-based PSI elements in this file (including the current one) * to be switched from stub to AST. So, after this call {@link #getStub()} will return null. */ @Override @Nonnull public ASTNode getNode() { if (mySubstrateRef instanceof SubstrateRef.StubRef) { ApplicationManager.getApplication().assertReadAccessAllowed(); PsiFileImpl file = (PsiFileImpl)getContainingFile(); if (!file.isValid()) throw new PsiInvalidElementAccessException(file); FileElement treeElement = file.getTreeElement(); if (treeElement != null && mySubstrateRef instanceof SubstrateRef.StubRef) { return notBoundInExistingAst(file, treeElement); } treeElement = file.calcTreeElement(); if (mySubstrateRef instanceof SubstrateRef.StubRef) { return failedToBindStubToAst(file, treeElement); } } return mySubstrateRef.getNode(); }
Example #11
Source File: CompletionInitializationUtil.java From consulo with Apache License 2.0 | 6 votes |
static OffsetsInFile toInjectedIfAny(PsiFile originalFile, OffsetsInFile hostCopyOffsets) { CompletionAssertions.assertHostInfo(hostCopyOffsets.getFile(), hostCopyOffsets.getOffsets()); int hostStartOffset = hostCopyOffsets.getOffsets().getOffset(CompletionInitializationContext.START_OFFSET); OffsetsInFile translatedOffsets = hostCopyOffsets.toInjectedIfAny(hostStartOffset); if (translatedOffsets != hostCopyOffsets) { PsiFile injected = translatedOffsets.getFile(); if (originalFile != injected && injected instanceof PsiFileImpl && InjectedLanguageManager.getInstance(originalFile.getProject()).isInjectedFragment(originalFile)) { ((PsiFileImpl)injected).setOriginalFile(originalFile); } DocumentWindow documentWindow = InjectedLanguageUtil.getDocumentWindow(injected); CompletionAssertions.assertInjectedOffsets(hostStartOffset, injected, documentWindow); if (injected.getTextRange().contains(translatedOffsets.getOffsets().getOffset(CompletionInitializationContext.START_OFFSET))) { return translatedOffsets; } } return hostCopyOffsets; }
Example #12
Source File: PomModelImpl.java From consulo with Apache License 2.0 | 6 votes |
private void reparseParallelTrees(PsiFile changedFile, PsiToDocumentSynchronizer synchronizer) { List<PsiFile> allFiles = changedFile.getViewProvider().getAllFiles(); if (allFiles.size() <= 1) { return; } CharSequence newText = changedFile.getNode().getChars(); for (final PsiFile file : allFiles) { FileElement fileElement = file == changedFile ? null : ((PsiFileImpl)file).getTreeElement(); Runnable changeAction = fileElement == null ? null : reparseFile(file, fileElement, newText); if (changeAction == null) continue; synchronizer.setIgnorePsiEvents(true); try { CodeStyleManager.getInstance(file.getProject()).performActionWithFormatterDisabled(changeAction); } finally { synchronizer.setIgnorePsiEvents(false); } } }
Example #13
Source File: LowLevelSearchUtil.java From consulo with Apache License 2.0 | 6 votes |
private static void diagnoseInvalidRange(@Nonnull PsiElement scope, PsiFile file, FileViewProvider viewProvider, CharSequence buffer, TextRange range) { String msg = "Range for element: '" + scope + "' = " + range + " is out of file '" + file + "' range: " + file.getTextRange(); msg += "; file contents length: " + buffer.length(); msg += "\n file provider: " + viewProvider; Document document = viewProvider.getDocument(); if (document != null) { msg += "\n committed=" + PsiDocumentManager.getInstance(file.getProject()).isCommitted(document); } for (Language language : viewProvider.getLanguages()) { final PsiFile root = viewProvider.getPsi(language); msg += "\n root " + language + " length=" + root.getTextLength() + (root instanceof PsiFileImpl ? "; contentsLoaded=" + ((PsiFileImpl)root).isContentsLoaded() : ""); } LOG.error(msg); }
Example #14
Source File: StubTreeLoaderImpl.java From consulo with Apache License 2.0 | 6 votes |
private void diagnoseLengthMismatch(VirtualFile vFile, boolean wasIndexedAlready, @Nullable Document document, boolean saved, @Nullable PsiFile cachedPsi) { String message = "Outdated stub in index: " + vFile + " " + getIndexingStampInfo(vFile) + ", doc=" + document + ", docSaved=" + saved + ", wasIndexedAlready=" + wasIndexedAlready + ", queried at " + vFile.getTimeStamp(); message += "\ndoc length=" + (document == null ? -1 : document.getTextLength()) + "\nfile length=" + vFile.getLength(); if (cachedPsi != null) { message += "\ncached PSI " + cachedPsi.getClass(); if (cachedPsi instanceof PsiFileImpl && ((PsiFileImpl)cachedPsi).isContentsLoaded()) { message += "\nPSI length=" + cachedPsi.getTextLength(); } List<Project> projects = ContainerUtil.findAll(ProjectManager.getInstance().getOpenProjects(), p -> PsiManagerEx.getInstanceEx(p).getFileManager().findCachedViewProvider(vFile) != null); message += "\nprojects with file: " + (LOG.isDebugEnabled() ? projects.toString() : projects.size()); } processError(vFile, message, new Exception()); }
Example #15
Source File: UsageViewTest.java From consulo with Apache License 2.0 | 6 votes |
public void testUsageViewDoesNotHoldPsiFilesOrDocuments() throws Exception { PsiFile psiFile = createFile("X.java", "public class X{} //iuggjhfg"); Usage[] usages = new Usage[100]; for (int i = 0; i < usages.length; i++) { usages[i] = createUsage(psiFile,i); } UsageView usageView = UsageViewManager.getInstance(getProject()).createUsageView(UsageTarget.EMPTY_ARRAY, usages, new UsageViewPresentation(), null); Disposer.register(getTestRootDisposable(), usageView); ((EncodingManagerImpl)EncodingManager.getInstance()).clearDocumentQueue(); FileDocumentManager.getInstance().saveAllDocuments(); UIUtil.dispatchAllInvocationEvents(); LeakHunter.checkLeak(usageView, PsiFileImpl.class); LeakHunter.checkLeak(usageView, Document.class); }
Example #16
Source File: FileIncludeManagerImpl.java From consulo with Apache License 2.0 | 6 votes |
@Nullable private PsiFileSystemItem doResolve(@Nonnull final FileIncludeInfo info, @Nonnull final PsiFile context) { if (info instanceof FileIncludeInfoImpl) { String id = ((FileIncludeInfoImpl)info).providerId; FileIncludeProvider provider = id == null ? null : myProviderMap.get(id); final PsiFileSystemItem resolvedByProvider = provider == null ? null : provider.resolveIncludedFile(info, context); if (resolvedByProvider != null) { return resolvedByProvider; } } PsiFileImpl psiFile = (PsiFileImpl)myPsiFileFactory.createFileFromText("dummy.txt", PlainTextFileType.INSTANCE, info.path); psiFile.setOriginalFile(context); return new FileReferenceSet(psiFile) { @Override protected boolean useIncludingFileAsContext() { return false; } }.resolve(); }
Example #17
Source File: FluidFileViewProvider.java From idea-php-typo3-plugin with MIT License | 6 votes |
@Nullable @Override protected PsiFile createFile(@NotNull Language lang) { if (lang == myTemplateDataLanguage) { PsiFileImpl file = (PsiFileImpl) LanguageParserDefinitions.INSTANCE.forLanguage(lang).createFile(this); file.setContentElementType(TEMPLATE_DATA); return file; } else if (lang == FluidLanguage.INSTANCE) { return LanguageParserDefinitions.INSTANCE.forLanguage(lang).createFile(this); } else { return null; } }
Example #18
Source File: DiffLog.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull public TreeChangeEventImpl performActualPsiChange(@Nonnull PsiFile file) { TreeAspect modelAspect = PomManager.getModel(file.getProject()).getModelAspect(TreeAspect.class); TreeChangeEventImpl event = new TreeChangeEventImpl(modelAspect, ((PsiFileImpl)file).calcTreeElement()); for (LogEntry entry : myEntries) { entry.doActualPsiChange(file, event); } file.subtreeChanged(); return event; }
Example #19
Source File: TemplateDataElementType.java From consulo with Apache License 2.0 | 5 votes |
@Override public ASTNode parseContents(ASTNode chameleon) { final CharTable charTable = SharedImplUtil.findCharTableByTree(chameleon); final FileElement fileElement = TreeUtil.getFileElement((TreeElement)chameleon); final PsiFile psiFile = (PsiFile)fileElement.getPsi(); PsiFile originalPsiFile = psiFile.getOriginalFile(); final TemplateLanguageFileViewProvider viewProvider = (TemplateLanguageFileViewProvider)originalPsiFile.getViewProvider(); final Language templateLanguage = getTemplateFileLanguage(viewProvider); final CharSequence sourceCode = chameleon.getChars(); RangesCollector collector = new RangesCollector(); final PsiFile templatePsiFile = createTemplateFile(psiFile, templateLanguage, sourceCode, viewProvider, collector); final FileElement templateFileElement = ((PsiFileImpl)templatePsiFile).calcTreeElement(); DebugUtil.startPsiModification("template language parsing"); try { prepareParsedTemplateFile(templateFileElement); insertOuters(templateFileElement, sourceCode, collector.myRanges, charTable); TreeElement childNode = templateFileElement.getFirstChildNode(); DebugUtil.checkTreeStructure(templateFileElement); DebugUtil.checkTreeStructure(chameleon); if (fileElement != chameleon) { DebugUtil.checkTreeStructure(psiFile.getNode()); DebugUtil.checkTreeStructure(originalPsiFile.getNode()); } return childNode; } finally { DebugUtil.finishPsiModification(); } }
Example #20
Source File: DiffLog.java From consulo with Apache License 2.0 | 5 votes |
@Override void doActualPsiChange(@Nonnull PsiFile file, @Nonnull TreeChangeEventImpl event) { PsiFileImpl fileImpl = (PsiFileImpl)file; final int oldLength = myOldNode.getTextLength(); PsiManagerImpl manager = (PsiManagerImpl)fileImpl.getManager(); BlockSupportImpl.sendBeforeChildrenChangeEvent(manager, fileImpl, false); if (myOldNode.getFirstChildNode() != null) myOldNode.rawRemoveAllChildren(); final TreeElement firstChildNode = myNewNode.getFirstChildNode(); if (firstChildNode != null) myOldNode.rawAddChildren(firstChildNode); fileImpl.calcTreeElement().setCharTable(myNewNode.getCharTable()); myOldNode.subtreeChanged(); BlockSupportImpl.sendAfterChildrenChangedEvent(manager, fileImpl, oldLength, false); }
Example #21
Source File: DocumentCommitThread.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull private static List<Pair<PsiFileImpl, FileASTNode>> getAllFileNodes(@Nonnull PsiFile file) { if (!file.isValid()) { throw new PsiInvalidElementAccessException(file, "File " + file + " is invalid, can't commit"); } if (file instanceof PsiCompiledFile) { throw new IllegalArgumentException("Can't commit ClsFile: " + file); } return ContainerUtil.map(file.getViewProvider().getAllFiles(), root -> Pair.create((PsiFileImpl)root, root.getNode())); }
Example #22
Source File: DustFileViewProvider.java From Intellij-Dust with MIT License | 5 votes |
@Override protected PsiFile createFile(Language lang) { // creating file for main lang (HTML) if (lang == myTemplateDataLanguage) { PsiFileImpl file = (PsiFileImpl) LanguageParserDefinitions.INSTANCE.forLanguage(lang).createFile(this); file.setContentElementType(templateDataElementType); return file; } else if (lang == DustLanguage.INSTANCE) { return LanguageParserDefinitions.INSTANCE.forLanguage(lang).createFile(this); } else { return null; } }
Example #23
Source File: PsiFileGistImpl.java From consulo with Apache License 2.0 | 5 votes |
private static PsiFile getPsiFile(@Nonnull Project project, @Nonnull VirtualFile file) { PsiFile psi = PsiManager.getInstance(project).findFile(file); if (!(psi instanceof PsiFileImpl) || ((PsiFileImpl)psi).isContentsLoaded()) { return psi; } FileType fileType = file.getFileType(); if (!(fileType instanceof LanguageFileType)) return null; return FileContentImpl.createFileFromText(project, psi.getViewProvider().getContents(), (LanguageFileType)fileType, file, file.getName()); }
Example #24
Source File: BlockSupportImpl.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull public static DiffLog mergeTrees(@Nonnull final PsiFileImpl fileImpl, @Nonnull final ASTNode oldRoot, @Nonnull final ASTNode newRoot, @Nonnull ProgressIndicator indicator, @Nonnull CharSequence lastCommittedText) { PsiUtilCore.ensureValid(fileImpl); if (newRoot instanceof FileElement) { FileElement fileImplElement = fileImpl.getTreeElement(); if (fileImplElement != null) { ((FileElement)newRoot).setCharTable(fileImplElement.getCharTable()); } } try { newRoot.putUserData(TREE_TO_BE_REPARSED, Pair.create(oldRoot, lastCommittedText)); if (isReplaceWholeNode(fileImpl, newRoot)) { DiffLog treeChangeEvent = replaceElementWithEvents(oldRoot, newRoot); fileImpl.putUserData(TREE_DEPTH_LIMIT_EXCEEDED, Boolean.TRUE); return treeChangeEvent; } newRoot.getFirstChildNode(); // maybe reparsed in PsiBuilderImpl and have thrown exception here } catch (ReparsedSuccessfullyException e) { // reparsed in PsiBuilderImpl return e.getDiffLog(); } finally { newRoot.putUserData(TREE_TO_BE_REPARSED, null); } final ASTShallowComparator comparator = new ASTShallowComparator(indicator); final ASTStructure treeStructure = createInterruptibleASTStructure(newRoot, indicator); DiffLog diffLog = new DiffLog(); diffTrees(oldRoot, diffLog, comparator, treeStructure, indicator, lastCommittedText); return diffLog; }
Example #25
Source File: FileBasedIndexImpl.java From consulo with Apache License 2.0 | 5 votes |
private static void initFileContent(@Nonnull FileContentImpl fc, Project project, PsiFile psiFile) { if (psiFile != null) { psiFile.putUserData(PsiFileImpl.BUILDING_STUB, true); fc.putUserData(IndexingDataKeys.PSI_FILE, psiFile); } fc.putUserData(IndexingDataKeys.PROJECT, project); }
Example #26
Source File: InjectionRegistrarImpl.java From consulo with Apache License 2.0 | 5 votes |
private static void mergePsi(@Nonnull PsiFile oldFile, @Nonnull ASTNode oldFileNode, @Nonnull PsiFile injectedPsi, @Nonnull ASTNode injectedNode) { if (!oldFile.textMatches(injectedPsi)) { InjectedFileViewProvider oldViewProvider = (InjectedFileViewProvider)oldFile.getViewProvider(); oldViewProvider.performNonPhysically(() -> DebugUtil.performPsiModification("injected tree diff", () -> { final DiffLog diffLog = BlockSupportImpl.mergeTrees((PsiFileImpl)oldFile, oldFileNode, injectedNode, new DaemonProgressIndicator(), oldFileNode.getText()); diffLog.doActualPsiChange(oldFile); })); } }
Example #27
Source File: TreeElement.java From consulo with Apache License 2.0 | 5 votes |
final void setTreeParent(CompositeElement parent) { if (parent == myParent) return; PsiFileImpl file = getCachedFile(this); if (file != null) { file.beforeAstChange(); } myParent = parent; if (parent != null && parent.getElementType() != TokenType.DUMMY_HOLDER) { DebugUtil.revalidateNode(this); } }
Example #28
Source File: PsiAnchor.java From consulo with Apache License 2.0 | 5 votes |
private static boolean canHaveStub(@Nonnull PsiFile file) { if (!(file instanceof PsiFileImpl)) return false; VirtualFile vFile = file.getVirtualFile(); IStubFileElementType elementType = ((PsiFileImpl)file).getElementTypeForStubBuilder(); return elementType != null && vFile != null && elementType.shouldBuildStubFor(vFile); }
Example #29
Source File: PsiAnchor.java From consulo with Apache License 2.0 | 5 votes |
public static int calcStubIndex(@Nonnull StubBasedPsiElement psi) { if (psi instanceof PsiFile) { return 0; } StubElement liveStub = psi instanceof StubBasedPsiElementBase ? ((StubBasedPsiElementBase)psi).getGreenStub() : psi.getStub(); if (liveStub != null) { return ((StubBase)liveStub).getStubId(); } return ((PsiFileImpl)psi.getContainingFile()).calcTreeElement().getStubbedSpine().getStubIndex(psi); }
Example #30
Source File: StubTreeLoaderImpl.java From consulo with Apache License 2.0 | 5 votes |
private static int getCurrentTextContentLength(Project project, VirtualFile vFile, Document document, PsiFile psiFile) { if (vFile.getFileType().isBinary()) { return -1; } if (psiFile instanceof PsiFileImpl && ((PsiFileImpl)psiFile).isContentsLoaded()) { return psiFile.getTextLength(); } if (document != null) { return PsiDocumentManager.getInstance(project).getLastCommittedText(document).length(); } return -1; }