本文整理汇总了Java中com.intellij.psi.stubs.StubBase类的典型用法代码示例。如果您正苦于以下问题:Java StubBase类的具体用法?Java StubBase怎么用?Java StubBase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StubBase类属于com.intellij.psi.stubs包,在下文中一共展示了StubBase类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: applyAnnotations
import com.intellij.psi.stubs.StubBase; //导入依赖的package包/类
@NotNull
public TypeInfo applyAnnotations(@NotNull StubBase<?> owner) {
PsiModifierListStub modifierList = (PsiModifierListStub)owner.findChildStubByType(JavaStubElementTypes.MODIFIER_LIST);
if (modifierList == null) return this;
List<PsiAnnotationStub> annotationStubs = null;
for (StubElement child : modifierList.getChildrenStubs()) {
if (!(child instanceof PsiAnnotationStub)) continue;
PsiAnnotationStub annotationStub = (PsiAnnotationStub)child;
if (PsiImplUtil.isTypeAnnotation(annotationStub.getPsiElement())) {
if (annotationStubs == null) annotationStubs = new SmartList<PsiAnnotationStub>();
annotationStubs.add(annotationStub);
}
}
PsiAnnotationStub[] stubArray = PsiAnnotationStub.EMPTY_ARRAY;
if (annotationStubs != null) stubArray = annotationStubs.toArray(new PsiAnnotationStub[annotationStubs.size()]);
return new TypeInfo(text, arrayCount, isEllipsis, stubArray);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:TypeInfo.java
示例2: calcStubIndex
import com.intellij.psi.stubs.StubBase; //导入依赖的package包/类
public static int calcStubIndex(@NotNull StubBasedPsiElement psi) {
if (psi instanceof PsiFile) {
return 0;
}
final StubElement liveStub = psi.getStub();
if (liveStub != null) {
return ((StubBase)liveStub).id;
}
PsiFileImpl file = (PsiFileImpl)psi.getContainingFile();
final StubTree stubTree = file.calcStubTree();
for (StubElement<?> stb : stubTree.getPlainList()) {
if (stb.getPsi() == psi) {
return ((StubBase)stb).id;
}
}
return -1; // it is possible via custom stub builder intentionally not producing stubs for stubbed elements
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:PsiAnchor.java
示例3: calcStubIndex
import com.intellij.psi.stubs.StubBase; //导入依赖的package包/类
public static int calcStubIndex(StubBasedPsiElement psi) {
if (psi instanceof PsiFile) {
return 0;
}
final StubElement liveStub = psi.getStub();
if (liveStub != null) {
return ((StubBase)liveStub).id;
}
PsiFileImpl file = (PsiFileImpl)psi.getContainingFile();
final StubTree stubTree = file.calcStubTree();
for (StubElement<?> stb : stubTree.getPlainList()) {
if (stb.getPsi() == psi) {
return ((StubBase)stb).id;
}
}
return -1; // it is possible via custom stub builder intentionally not producing stubs for stubbed elements
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:21,代码来源:PsiAnchor.java
示例4: calcStubIndex
import com.intellij.psi.stubs.StubBase; //导入依赖的package包/类
public static int calcStubIndex(@Nonnull StubBasedPsiElement psi) {
if (psi instanceof PsiFile) {
return 0;
}
final StubElement liveStub = psi.getStub();
if (liveStub != null) {
return ((StubBase)liveStub).id;
}
PsiFileImpl file = (PsiFileImpl)psi.getContainingFile();
final StubTree stubTree = file.calcStubTree();
for (StubElement<?> stb : stubTree.getPlainList()) {
if (stb.getPsi() == psi) {
return ((StubBase)stb).id;
}
}
return -1; // it is possible via custom stub builder intentionally not producing stubs for stubbed elements
}
开发者ID:consulo,项目名称:consulo,代码行数:21,代码来源:PsiAnchor.java
示例5: getStubOrPsiParent
import com.intellij.psi.stubs.StubBase; //导入依赖的package包/类
@Nullable
@Contract("null -> null")
public static PsiElement getStubOrPsiParent(@Nullable PsiElement element) {
if (element instanceof StubBasedPsiElement) {
StubBase stub = (StubBase)((StubBasedPsiElement)element).getStub();
if (stub != null) {
//noinspection unchecked
final StubElement parentStub = stub.getParentStub();
return parentStub != null ? parentStub.getPsi() : null;
}
}
return element != null ? element.getParent() : null;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:PsiTreeUtil.java
示例6: getStubOrPsiParentOfType
import com.intellij.psi.stubs.StubBase; //导入依赖的package包/类
@Nullable
@Contract("null, _ -> null")
public static <E extends PsiElement> E getStubOrPsiParentOfType(@Nullable PsiElement element, @NotNull Class<E> parentClass) {
if (element instanceof StubBasedPsiElement) {
StubBase stub = (StubBase)((StubBasedPsiElement)element).getStub();
if (stub != null) {
//noinspection unchecked
return (E)stub.getParentStubOfType(parentClass);
}
}
return getParentOfType(element, parentClass);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:PsiTreeUtil.java
示例7: applyAnnotations
import com.intellij.psi.stubs.StubBase; //导入依赖的package包/类
@NotNull
public TypeInfo applyAnnotations(@NotNull StubBase<?> owner) {
PsiModifierListStub modifierList = (PsiModifierListStub)owner.findChildStubByType(JavaStubElementTypes.MODIFIER_LIST);
if (modifierList == null) return this;
List<PsiAnnotationStub> annotationStubs = ContainerUtil.newArrayList();
for (StubElement child : modifierList.getChildrenStubs()) {
if (!(child instanceof PsiAnnotationStub)) continue;
PsiAnnotationStub annotationStub = (PsiAnnotationStub)child;
if (PsiImplUtil.findApplicableTarget(annotationStub.getPsiElement(), TargetType.TYPE_USE) == TargetType.TYPE_USE) {
annotationStubs.add(annotationStub);
}
}
return new TypeInfo(text, arrayCount, isEllipsis, annotationStubs);
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:16,代码来源:TypeInfo.java
示例8: getStubOrPsiParentOfType
import com.intellij.psi.stubs.StubBase; //导入依赖的package包/类
@Nullable
@Contract("null, _ -> null")
public static <E extends PsiElement> E getStubOrPsiParentOfType(@Nullable PsiElement element, @Nonnull Class<E> parentClass) {
if (element instanceof StubBasedPsiElement) {
StubBase stub = (StubBase)((StubBasedPsiElement)element).getStub();
if (stub != null) {
//noinspection unchecked
return (E)stub.getParentStubOfType(parentClass);
}
}
return getParentOfType(element, parentClass);
}
开发者ID:consulo,项目名称:consulo,代码行数:13,代码来源:PsiTreeUtil.java
示例9: applyAnnotations
import com.intellij.psi.stubs.StubBase; //导入依赖的package包/类
@NotNull
public TypeInfo applyAnnotations(@NotNull StubBase<?> owner)
{
PsiModifierListStub modifierList = (PsiModifierListStub) owner.findChildStubByType(JavaStubElementTypes.MODIFIER_LIST);
if(modifierList == null)
{
return this;
}
List<PsiAnnotationStub> annotationStubs = null;
for(StubElement child : modifierList.getChildrenStubs())
{
if(!(child instanceof PsiAnnotationStub))
{
continue;
}
PsiAnnotationStub annotationStub = (PsiAnnotationStub) child;
if(PsiImplUtil.isTypeAnnotation(annotationStub.getPsiElement()))
{
if(annotationStubs == null)
{
annotationStubs = new SmartList<PsiAnnotationStub>();
}
annotationStubs.add(annotationStub);
}
}
PsiAnnotationStub[] stubArray = PsiAnnotationStub.EMPTY_ARRAY;
if(annotationStubs != null)
{
stubArray = annotationStubs.toArray(new PsiAnnotationStub[annotationStubs.size()]);
}
return new TypeInfo(text, arrayCount, isEllipsis, stubArray);
}
开发者ID:consulo,项目名称:consulo-java,代码行数:35,代码来源:TypeInfo.java
示例10: restoreFromStubIndex
import com.intellij.psi.stubs.StubBase; //导入依赖的package包/类
@Nullable
public static PsiElement restoreFromStubIndex(PsiFileWithStubSupport fileImpl,
int index,
@NotNull IStubElementType elementType, boolean throwIfNull) {
if (fileImpl == null) {
if (throwIfNull) throw new AssertionError("Null file");
return null;
}
StubTree tree = fileImpl.getStubTree();
boolean foreign = tree == null;
if (foreign) {
if (fileImpl instanceof PsiFileImpl) {
// Note: as far as this is a realization of StubIndexReference fileImpl#getContentElementType() must be instance of IStubFileElementType
tree = ((PsiFileImpl)fileImpl).calcStubTree();
}
else {
if (throwIfNull) throw new AssertionError("Not PsiFileImpl: " + fileImpl.getClass());
return null;
}
}
List<StubElement<?>> list = tree.getPlainList();
if (index >= list.size()) {
if (throwIfNull) throw new AssertionError("Too large index: " + index + ">=" + list.size());
return null;
}
StubElement stub = list.get(index);
if (stub.getStubType() != elementType) {
if (throwIfNull) throw new AssertionError("Element type mismatch: " + stub.getStubType() + "!=" + elementType);
return null;
}
if (foreign) {
final PsiElement cachedPsi = ((StubBase)stub).getCachedPsi();
if (cachedPsi != null) return cachedPsi;
final ASTNode ast = fileImpl.findTreeForStub(tree, stub);
if (ast != null) {
return ast.getPsi();
}
if (throwIfNull) throw new AssertionError("No AST for stub");
return null;
}
return stub.getPsi();
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:49,代码来源:PsiAnchor.java
示例11: main
import com.intellij.psi.stubs.StubBase; //导入依赖的package包/类
public static void main(String[] args) throws ClassNotFoundException {
String source = args.length == 0 ? DEFAULT_SOURCE : args[0];
PsiFile psi = LightPsi.parseFile("dummy", source, new SchemaParserDefinition());
String psiDump = DebugUtil.psiToString(psi, true, false).trim();
System.out.println(psiDump);
// load file parsing related classes
try {
LightPsi.parseFile(new File("."), new SchemaParserDefinition());
} catch (IOException e) {
// e.printStackTrace();
}
// force some class loading
@SuppressWarnings({"unused", "MismatchedReadAndWriteOfArray"})
Class<?>[] classes = new Class[]{
PsiTreeUtil.class,
StubBasedPsiElementBase.class,
StubBase.class,
StubOutputStream.class,
StubInputStream.class,
IndexSink.class,
ASTWrapperPsiElement.class,
PsiElementProcessor.class,
ParserDefinition.SpaceRequirements.class,
PsiDirectory.class,
};
String[] extraClasses = {
"com.intellij.lang.parser.GeneratedParserUtilBase$CompletionState",
"com.intellij.lang.parser.GeneratedParserUtilBase$Hooks",
"com.intellij.lang.parser.GeneratedParserUtilBase$DummyBlock",
"com.intellij.psi.impl.source.SubstrateRef$StubRef",
"com.intellij.extapi.psi.StubBasedPsiElementBase$1",
};
for (String extraClass : extraClasses) {
Class.forName(extraClass);
}
}
开发者ID:SumoLogic,项目名称:epigraph,代码行数:42,代码来源:Main.java
注:本文中的com.intellij.psi.stubs.StubBase类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论