本文整理汇总了Java中com.intellij.psi.tree.IStubFileElementType类的典型用法代码示例。如果您正苦于以下问题:Java IStubFileElementType类的具体用法?Java IStubFileElementType怎么用?Java IStubFileElementType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IStubFileElementType类属于com.intellij.psi.tree包,在下文中一共展示了IStubFileElementType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: canHaveStub
import com.intellij.psi.tree.IStubFileElementType; //导入依赖的package包/类
@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;
}
示例2: getCumulativeVersion
import com.intellij.psi.tree.IStubFileElementType; //导入依赖的package包/类
public static int getCumulativeVersion() {
int version = VERSION;
for (final FileType fileType : FileTypeRegistry.getInstance().getRegisteredFileTypes()) {
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) {
version += ((IStubFileElementType)type).getStubVersion();
}
}
}
BinaryFileStubBuilder builder = BinaryFileStubBuilders.INSTANCE.forFileType(fileType);
if (builder != null) {
version += builder.getStubVersion();
}
}
return version;
}
示例3: createElementInfo
import com.intellij.psi.tree.IStubFileElementType; //导入依赖的package包/类
@Override
@Nullable
public SmartPointerElementInfo createElementInfo(@NotNull PsiElement element, @NotNull PsiFile containingFile) {
if (element instanceof StubBasedPsiElement && containingFile instanceof PsiFileWithStubSupport) {
PsiFileWithStubSupport stubFile = (PsiFileWithStubSupport)containingFile;
StubTree stubTree = stubFile.getStubTree();
if (stubTree != null) {
// use stubs when tree is not loaded
StubBasedPsiElement stubPsi = (StubBasedPsiElement)element;
int stubId = PsiAnchor.calcStubIndex(stubPsi);
IStubElementType myStubElementType = stubPsi.getElementType();
IElementType contentElementType = ((PsiFileImpl)containingFile).getContentElementType();
if (stubId != -1 && contentElementType instanceof IStubFileElementType) { // TemplateDataElementType is not IStubFileElementType
return new AnchorElementInfo(element, stubFile, stubId, myStubElementType);
}
}
}
PsiElement anchor = getAnchor(element);
if (anchor != null) {
return new AnchorElementInfo(anchor, containingFile);
}
return null;
}
示例4: canHaveStub
import com.intellij.psi.tree.IStubFileElementType; //导入依赖的package包/类
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;
}
if (IndexingStamp.isFileIndexedStateCurrent(file, INDEX_ID)) {
return true;
}
}
}
final BinaryFileStubBuilder builder = BinaryFileStubBuilders.INSTANCE.forFileType(fileType);
return builder != null && builder.acceptsFile(file);
}
示例5: doTest
import com.intellij.psi.tree.IStubFileElementType; //导入依赖的package包/类
public void doTest() throws Exception {
final List<String> data = TestUtils.readInput(getTestDataPath() + "/" + getTestName(true) + ".test");
String fileText = data.get(0);
PsiFile psiFile = TestUtils.createPseudoPhysicalGroovyFile(getProject(), fileText);
ASTNode node = psiFile.getNode();
Assert.assertNotNull(node);
IElementType type = node.getElementType();
Assert.assertTrue(type instanceof IStubFileElementType);
IStubFileElementType stubFileType = (IStubFileElementType) type;
StubBuilder builder = stubFileType.getBuilder();
StubElement element = builder.buildStubTree(psiFile);
StringBuffer buffer = new StringBuffer();
getStubsTreeImpl(element, buffer, "");
String stubTree = buffer.toString().trim();
assertEquals(data.get(1), stubTree);
}
示例6: createStubReference
import com.intellij.psi.tree.IStubFileElementType; //导入依赖的package包/类
@Nullable
public static StubIndexReference createStubReference(@NotNull PsiElement element, @NotNull PsiFile containingFile) {
if (element instanceof StubBasedPsiElement &&
element.isPhysical() &&
(element instanceof PsiCompiledElement || ((PsiFileImpl)containingFile).getContentElementType() instanceof IStubFileElementType)) {
final StubBasedPsiElement elt = (StubBasedPsiElement)element;
final IStubElementType elementType = elt.getElementType();
if (elt.getStub() != null || elementType.shouldCreateStub(element.getNode())) {
int index = calcStubIndex((StubBasedPsiElement)element);
if (index != -1) {
return new StubIndexReference(containingFile, index, containingFile.getLanguage(), elementType);
}
}
}
return null;
}
示例7: canHaveStub
import com.intellij.psi.tree.IStubFileElementType; //导入依赖的package包/类
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;
}
final ID indexId = IndexInfrastructure.getStubId(INDEX_ID, file.getFileType());
if (IndexingStamp.isFileIndexed(file, indexId, IndexInfrastructure.getIndexCreationStamp(indexId))) {
return true;
}
}
}
final BinaryFileStubBuilder builder = BinaryFileStubBuilders.INSTANCE.forFileType(fileType);
return builder != null && builder.acceptsFile(file);
}
示例8: computeVersionMap
import com.intellij.psi.tree.IStubFileElementType; //导入依赖的package包/类
private static Map<FileType, Integer> computeVersionMap() {
Map<FileType, Integer> map = new HashMap<FileType, Integer>();
for (final FileType fileType : FileTypeManager.getInstance().getRegisteredFileTypes()) {
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) {
map.put(fileType, ((IStubFileElementType)type).getStubVersion());
}
}
}
final BinaryFileStubBuilder builder = BinaryFileStubBuilders.INSTANCE.forFileType(fileType);
if (builder != null) {
map.put(fileType, builder.getStubVersion());
}
}
return map;
}
示例9: createAnchorInfo
import com.intellij.psi.tree.IStubFileElementType; //导入依赖的package包/类
@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;
}
示例10: canHaveStub
import com.intellij.psi.tree.IStubFileElementType; //导入依赖的package包/类
public static boolean canHaveStub(@Nonnull 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);
}
示例11: getVersionOwner
import com.intellij.psi.tree.IStubFileElementType; //导入依赖的package包/类
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;
}
示例12: getStubbedRoots
import com.intellij.psi.tree.IStubFileElementType; //导入依赖的package包/类
/** Order is deterministic. First element matches {@link FileViewProvider#getStubBindingRoot()} */
@NotNull
public static List<Pair<IStubFileElementType, PsiFile>> getStubbedRoots(@NotNull FileViewProvider viewProvider) {
final List<Trinity<Language, IStubFileElementType, PsiFile>> roots =
new SmartList<Trinity<Language, IStubFileElementType, PsiFile>>();
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, new Comparator<Trinity<Language, IStubFileElementType, PsiFile>>() {
@Override
public int compare(Trinity<Language, IStubFileElementType, PsiFile> o1, Trinity<Language, IStubFileElementType, PsiFile> 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, new Function<Trinity<Language, IStubFileElementType, PsiFile>, Pair<IStubFileElementType, PsiFile>>() {
@Override
public Pair<IStubFileElementType, PsiFile> fun(Trinity<Language, IStubFileElementType, PsiFile> trinity) {
return Pair.create(trinity.second, trinity.third);
}
});
}
示例13: buildStubTree
import com.intellij.psi.tree.IStubFileElementType; //导入依赖的package包/类
@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;
}
Language language = ((LanguageFileType)fileType).getLanguage();
final IFileElementType contentType = LanguageParserDefinitions.INSTANCE.forLanguage(language).getFileNodeType();
if (!(contentType instanceof IStubFileElementType)) {
LOG.error("File is not of IStubFileElementType: " + contentType + ", " + file);
return null;
}
final FileASTNode node = file.getNode();
if (contentType 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;
}
示例14: canHaveStub
import com.intellij.psi.tree.IStubFileElementType; //导入依赖的package包/类
private static boolean canHaveStub(PsiFile file) {
if (!(file instanceof PsiFileImpl)) return false;
VirtualFile vFile = file.getVirtualFile();
IElementType elementType = ((PsiFileImpl)file).getContentElementType();
return elementType instanceof IStubFileElementType && vFile != null && ((IStubFileElementType)elementType).shouldBuildStubFor(vFile);
}
示例15: getStubTree
import com.intellij.psi.tree.IStubFileElementType; //导入依赖的package包/类
@Override
@Nullable
public StubTree getStubTree() {
ApplicationManager.getApplication().assertReadAccessAllowed();
if (Boolean.TRUE.equals(getUserData(BUILDING_STUB))) return null;
final StubTree derefd = derefStub();
if (derefd != null) return derefd;
if (getTreeElement() != null) return null;
if (!(getContentElementType() instanceof IStubFileElementType)) return null;
final VirtualFile vFile = getVirtualFile();
if (!(vFile instanceof VirtualFileWithId)) return null;
final PsiFile stubBindingRoot = getViewProvider().getStubBindingRoot();
if (stubBindingRoot != this) {
LOG.error("Attempted to create stubs for non-root file: " + this + ", stub binding root: " + stubBindingRoot);
return null;
}
ObjectStubTree tree = StubTreeLoader.getInstance().readOrBuild(getProject(), vFile, this);
if (!(tree instanceof StubTree)) return null;
StubTree stubHolder = (StubTree)tree;
synchronized (PsiLock.LOCK) {
if (getTreeElement() != null) return null;
final StubTree derefdOnLock = derefStub();
if (derefdOnLock != null) return derefdOnLock;
//noinspection unchecked
((StubBase)stubHolder.getRoot()).setPsi(this);
myStub = new SoftReference<StubTree>(stubHolder);
return stubHolder;
}
}