use of com.intellij.psi.tree.IFileElementType in project intellij-community by JetBrains.
the class LightStubBuilder method buildStubTree.
@Override
public StubElement buildStubTree(@NotNull PsiFile file) {
LighterAST tree = FORCED_AST.get();
if (tree == null) {
FileType fileType = file.getFileType();
if (!(fileType instanceof LanguageFileType)) {
LOG.error("File is not of LanguageFileType: " + fileType + ", " + file);
return null;
}
assert file instanceof PsiFileImpl;
final IFileElementType contentType = ((PsiFileImpl) file).getElementTypeForStubBuilder();
if (contentType == null) {
LOG.error("File is not of IStubFileElementType: " + file);
return null;
}
final FileASTNode node = file.getNode();
if (node.getElementType() instanceof ILightStubFileElementType) {
tree = node.getLighterAST();
} else {
tree = new TreeBackedLighterAST(node);
}
} else {
FORCED_AST.set(null);
}
if (tree == null)
return null;
final StubElement rootStub = createStubForFile(file, tree);
buildStubTree(tree, tree.getRoot(), rootStub);
return rootStub;
}
use of com.intellij.psi.tree.IFileElementType in project intellij-community by JetBrains.
the class ChameleonSyntaxHighlightingPass method collectInformationWithProgress.
@Override
public void collectInformationWithProgress(@NotNull ProgressIndicator progress) {
SyntaxTraverser<PsiElement> s = psiTraverser(myFile).filter(o -> {
IElementType type = PsiUtilCore.getElementType(o);
return type instanceof ILazyParseableElementType && !(type instanceof IFileElementType);
});
List<PsiElement> lazyOutside = ContainerUtil.newArrayListWithCapacity(100);
List<PsiElement> lazyInside = ContainerUtil.newArrayListWithCapacity(100);
List<HighlightInfo> outside = ContainerUtil.newArrayListWithCapacity(100);
List<HighlightInfo> inside = ContainerUtil.newArrayListWithCapacity(100);
for (PsiElement e : s) {
(e.getTextRange().intersects(myPriorityRange) ? lazyInside : lazyOutside).add(e);
}
for (PsiElement e : lazyInside) {
collectHighlights(e, inside, outside, myPriorityRange);
}
myHighlightInfoProcessor.highlightsInsideVisiblePartAreProduced(myHighlightingSession, inside, myPriorityRange, myRestrictRange, getId());
for (PsiElement e : lazyOutside) {
collectHighlights(e, inside, outside, myPriorityRange);
}
myHighlightInfoProcessor.highlightsOutsideVisiblePartAreProduced(myHighlightingSession, outside, myPriorityRange, myRestrictRange, getId());
myHighlights.addAll(inside);
myHighlights.addAll(outside);
}
use of com.intellij.psi.tree.IFileElementType in project intellij-community by JetBrains.
the class CoreStubTreeLoader method canHaveStub.
@Override
public boolean canHaveStub(VirtualFile file) {
final FileType fileType = file.getFileType();
if (fileType instanceof LanguageFileType) {
Language l = ((LanguageFileType) fileType).getLanguage();
ParserDefinition parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(l);
if (parserDefinition == null)
return false;
final IFileElementType elementType = parserDefinition.getFileNodeType();
return elementType instanceof IStubFileElementType && ((IStubFileElementType) elementType).shouldBuildStubFor(file);
} else if (fileType.isBinary()) {
final BinaryFileStubBuilder builder = BinaryFileStubBuilders.INSTANCE.forFileType(fileType);
return builder != null && builder.acceptsFile(file);
}
return false;
}
use of com.intellij.psi.tree.IFileElementType in project intellij-community by JetBrains.
the class StubUpdatingIndex method canHaveStub.
public static boolean canHaveStub(@NotNull VirtualFile file) {
final FileType fileType = file.getFileType();
if (fileType instanceof LanguageFileType) {
final Language l = ((LanguageFileType) fileType).getLanguage();
final ParserDefinition parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(l);
if (parserDefinition == null) {
return false;
}
final IFileElementType elementType = parserDefinition.getFileNodeType();
if (elementType instanceof IStubFileElementType) {
if (((IStubFileElementType) elementType).shouldBuildStubFor(file)) {
return true;
}
FileBasedIndex fileBasedIndex = FileBasedIndex.getInstance();
if (file instanceof NewVirtualFile && fileBasedIndex instanceof FileBasedIndexImpl && ((FileBasedIndexImpl) fileBasedIndex).getIndex(INDEX_ID).isIndexedStateForFile(((NewVirtualFile) file).getId(), file)) {
return true;
}
}
}
final BinaryFileStubBuilder builder = BinaryFileStubBuilders.INSTANCE.forFileType(fileType);
return builder != null && builder.acceptsFile(file);
}
use of com.intellij.psi.tree.IFileElementType in project intellij-community by JetBrains.
the class StubVersionMap method getVersionOwner.
private static Object getVersionOwner(FileType fileType) {
Object owner = null;
if (fileType instanceof LanguageFileType) {
Language l = ((LanguageFileType) fileType).getLanguage();
ParserDefinition parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(l);
if (parserDefinition != null) {
final IFileElementType type = parserDefinition.getFileNodeType();
if (type instanceof IStubFileElementType) {
owner = type;
}
}
}
BinaryFileStubBuilder builder = BinaryFileStubBuilders.INSTANCE.forFileType(fileType);
if (builder != null) {
owner = builder;
}
return owner;
}
Aggregations