本文整理汇总了Java中com.intellij.psi.stubs.PsiFileStub类的典型用法代码示例。如果您正苦于以下问题:Java PsiFileStub类的具体用法?Java PsiFileStub怎么用?Java PsiFileStub使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PsiFileStub类属于com.intellij.psi.stubs包,在下文中一共展示了PsiFileStub类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visitInnerClass
import com.intellij.psi.stubs.PsiFileStub; //导入依赖的package包/类
@Override
public void visitInnerClass(final String name, final String outerName, final String innerName, final int access) {
if ((access & Opcodes.ACC_SYNTHETIC) != 0) return;
if (!isCorrectName(innerName) || outerName == null) return;
if ((getClassName(outerName) + "." + innerName).equals(myResult.getQualifiedName())) {
// our result is inner class
if (myParent instanceof PsiFileStub) {
throw new OutOfOrderInnerClassException();
}
}
if (!namesEqual(outerName, myResult.getQualifiedName())) {
return;
}
T innerClass = myInnersStrategy.findInnerClass(innerName, mySource);
if (innerClass != null) {
StubBuildingVisitor<T> visitor = new StubBuildingVisitor<T>(innerClass, myInnersStrategy, myResult, access, innerName);
myInnersStrategy.accept(innerClass, visitor);
}
}
示例2: isAnonymousOrLocal
import com.intellij.psi.stubs.PsiFileStub; //导入依赖的package包/类
private static boolean isAnonymousOrLocal(PsiClass aClass) {
if (aClass instanceof PsiAnonymousClass) return true;
final PsiClassStub stub = ((PsiClassImpl)aClass).getStub();
if (stub != null) {
final StubElement parentStub = stub.getParentStub();
return !(parentStub instanceof PsiClassStub || parentStub instanceof PsiFileStub);
}
PsiElement parent = aClass.getParent();
while (parent != null) {
if (parent instanceof PsiMethod || parent instanceof PsiField || parent instanceof PsiClassInitializer) return true;
if (parent instanceof PsiClass || parent instanceof PsiFile) return false;
parent = parent.getParent();
}
return false;
}
示例3: visitInnerClass
import com.intellij.psi.stubs.PsiFileStub; //导入依赖的package包/类
@Override
public void visitInnerClass(final String name, final String outerName, final String innerName, final int access) {
if ((access & Opcodes.ACC_SYNTHETIC) != 0) return;
if (!isCorrectName(innerName)) return;
if (innerName == null || outerName == null) return;
if ((getClassName(outerName) + "." + innerName).equals(myResult.getQualifiedName())) {
// Our result is inner class
if (myParent instanceof PsiFileStub) {
throw new OutOfOrderInnerClassException();
}
}
if (!getClassName(outerName).equals(myResult.getQualifiedName())) return;
final T innerSource = myInnersStrategy.findInnerClass(innerName, mySource);
if (innerSource == null) return;
final ClassReader reader = myInnersStrategy.readerForInnerClass(innerSource);
if (reader == null) return;
final StubBuildingVisitor<T> classVisitor = new StubBuildingVisitor<T>(innerSource, myInnersStrategy, myResult, access);
reader.accept(classVisitor, ClassReader.SKIP_FRAMES);
}
示例4: buildStubTree
import com.intellij.psi.stubs.PsiFileStub; //导入依赖的package包/类
@Override
public StubElement buildStubTree(FileContent fileContent) {
try {
VirtualFile file = fileContent.getFile();
Project project = fileContent.getProject();
byte[] content = fileContent.getContent();
final ClsStubBuilderFactory[] factories = Extensions.getExtensions(ClsStubBuilderFactory.EP_NAME);
for (ClsStubBuilderFactory factory : factories) {
if (!factory.isInnerClass(file) && factory.canBeProcessed(file, content)) {
PsiFileStub stub = factory.buildFileStub(file, content, project);
if (stub != null) return stub;
}
}
if (!fileContent.getFileName().contains("$")) {
LOG.info("No stub built for file " + fileContent);
}
return null;
}
catch (ClsFormatException e) {
return null;
}
}
示例5: visitInnerClass
import com.intellij.psi.stubs.PsiFileStub; //导入依赖的package包/类
@Override
public void visitInnerClass(String name, String outerName, String innerName, int access)
{
if(isSet(access, Opcodes.ACC_SYNTHETIC))
{
return;
}
if(innerName == null || outerName == null)
{
return;
}
if(myParent instanceof PsiFileStub && myInternalName.equals(name))
{
throw new OutOfOrderInnerClassException(); // our result is inner class
}
if(myInternalName.equals(outerName))
{
T innerClass = myInnersStrategy.findInnerClass(innerName, mySource);
if(innerClass != null)
{
myInnersStrategy.accept(innerClass, new StubBuildingVisitor<>(innerClass, myInnersStrategy, myResult, access, innerName));
}
}
}
示例6: getFileStub
import com.intellij.psi.stubs.PsiFileStub; //导入依赖的package包/类
private PsiJavaFileStub getFileStub(StubT stub) {
StubElement parent = stub;
while (!(parent instanceof PsiFileStub)) {
parent = parent.getParentStub();
}
return (PsiJavaFileStub)parent;
}
示例7: getContainingFile
import com.intellij.psi.stubs.PsiFileStub; //导入依赖的package包/类
@Override
public PsiFile getContainingFile() {
StubElement p = myStub;
while (!(p instanceof PsiFileStub)) {
p = p.getParentStub();
}
return (PsiFile)p.getPsi();
}
示例8: getParent
import com.intellij.psi.stubs.PsiFileStub; //导入依赖的package包/类
@Override
public PsiElement getParent() {
final PsiClassStub stub = getStub();
if (stub != null) {
final StubElement parentStub = stub.getParentStub();
if (parentStub instanceof PsiFileStub || parentStub instanceof PsiClassStub
) {
return parentStub.getPsi();
}
}
return SharedImplUtil.getParent(getNode());
}
示例9: getContainingFile
import com.intellij.psi.stubs.PsiFileStub; //导入依赖的package包/类
@Nonnull
@Override
public PsiFile getContainingFile() {
StubElement stub = myStub;
while (!(stub instanceof PsiFileStub)) {
stub = stub.getParentStub();
}
PsiFile psi = (PsiFile)stub.getPsi();
if (psi != null) {
return psi;
}
return reportError(stub);
}
示例10: visitOuterClass
import com.intellij.psi.stubs.PsiFileStub; //导入依赖的package包/类
@Override
public void visitOuterClass(String owner, String name, String desc)
{
if(myParent instanceof PsiFileStub)
{
throw new OutOfOrderInnerClassException();
}
}
示例11: isAnonymousOrLocal
import com.intellij.psi.stubs.PsiFileStub; //导入依赖的package包/类
private static boolean isAnonymousOrLocal(PsiClass aClass)
{
if(aClass instanceof PsiAnonymousClass)
{
return true;
}
final PsiClassStub stub = ((PsiClassImpl) aClass).getGreenStub();
if(stub != null)
{
final StubElement parentStub = stub.getParentStub();
return !(parentStub instanceof PsiClassStub || parentStub instanceof PsiFileStub);
}
PsiElement parent = aClass.getParent();
while(parent != null)
{
if(parent instanceof PsiMethod || parent instanceof PsiField || parent instanceof PsiClassInitializer)
{
return true;
}
if(parent instanceof PsiClass || parent instanceof PsiFile)
{
return false;
}
parent = parent.getParent();
}
return false;
}
示例12: buildFileStub
import com.intellij.psi.stubs.PsiFileStub; //导入依赖的package包/类
public PsiFileStub<T> buildFileStub(final VirtualFile file, byte[] bytes, Project project) throws ClsFormatException {
return buildFileStub(file, bytes);
}
示例13: visitOuterClass
import com.intellij.psi.stubs.PsiFileStub; //导入依赖的package包/类
@Override
public void visitOuterClass(final String owner, final String name, final String desc) {
if (myParent instanceof PsiFileStub) {
throw new OutOfOrderInnerClassException();
}
}
示例14: packModifierList
import com.intellij.psi.stubs.PsiFileStub; //导入依赖的package包/类
public static int packModifierList(@NotNull LighterAST tree, @NotNull LighterASTNode modList, @NotNull StubElement parent) {
int packed = 0;
final LighterASTNode modListOwner = tree.getParent(modList);
if (modListOwner != null && modListOwner.getTokenType() == parent.getStubType()) {
final StubElement grandParent = parent.getParentStub();
if (parent instanceof PsiClassStub) {
if (grandParent instanceof PsiClassStub && ((PsiClassStub)grandParent).isInterface()) {
packed |= ModifierFlags.PUBLIC_MASK;
packed |= ModifierFlags.STATIC_MASK;
}
if (((PsiClassStub)parent).isInterface()) {
packed |= ModifierFlags.ABSTRACT_MASK;
if (grandParent instanceof PsiClassStub) {
packed |= ModifierFlags.STATIC_MASK;
}
}
else if (((PsiClassStub)parent).isEnum()) {
if (!(grandParent instanceof PsiFileStub)) {
packed |= ModifierFlags.STATIC_MASK;
}
boolean isFinal = true;
final List<LighterASTNode> enumConstants = LightTreeUtil.getChildrenOfType(tree, modListOwner, JavaElementType.ENUM_CONSTANT);
for (final LighterASTNode constant : enumConstants) {
if (LightTreeUtil.firstChildOfType(tree, constant, JavaElementType.ENUM_CONSTANT_INITIALIZER) != null) {
isFinal = false;
break;
}
}
if (isFinal) {
packed |= ModifierFlags.FINAL_MASK;
}
final List<LighterASTNode> methods = LightTreeUtil.getChildrenOfType(tree, modListOwner, JavaElementType.METHOD);
for (final LighterASTNode method : methods) {
final LighterASTNode mods = LightTreeUtil.requiredChildOfType(tree, method, JavaElementType.MODIFIER_LIST);
if (LightTreeUtil.firstChildOfType(tree, mods, JavaTokenType.ABSTRACT_KEYWORD) != null) {
packed |= ModifierFlags.ABSTRACT_MASK;
break;
}
}
}
}
else if (parent instanceof PsiMethodStub) {
if (grandParent instanceof PsiClassStub && ((PsiClassStub)grandParent).isInterface()) {
packed |= ModifierFlags.PUBLIC_MASK;
packed |= ModifierFlags.ABSTRACT_MASK;
}
}
else if (parent instanceof PsiFieldStub) {
if (parent.getStubType() == JavaElementType.ENUM_CONSTANT ||
grandParent instanceof PsiClassStub && ((PsiClassStub)grandParent).isInterface()) {
packed |= ModifierFlags.PUBLIC_MASK;
packed |= ModifierFlags.STATIC_MASK;
packed |= ModifierFlags.FINAL_MASK;
}
}
}
for (final LighterASTNode child : tree.getChildren(modList)) {
final int flag = ModifierFlags.KEYWORD_TO_MODIFIER_FLAG_MAP.get(child.getTokenType());
if (flag != 0) {
packed |= flag;
}
}
if ((packed & ModifierFlags.DEFENDER_MASK) != 0) {
packed &= ~ModifierFlags.ABSTRACT_MASK;
}
if ((packed & (ModifierFlags.PRIVATE_MASK | ModifierFlags.PROTECTED_MASK | ModifierFlags.PUBLIC_MASK)) == 0) {
packed |= ModifierFlags.PACKAGE_LOCAL_MASK;
}
return packed;
}
示例15: reason
import com.intellij.psi.stubs.PsiFileStub; //导入依赖的package包/类
@NonNls
@NotNull
private static String reason(@NotNull PsiElement root) {
if (root == PsiUtilCore.NULL_PSI_ELEMENT) return "NULL_PSI_ELEMENT";
PsiElement element = root instanceof PsiFile ? root : root.getParent();
if (element == null) {
String m = "parent is null";
if (root instanceof StubBasedPsiElement) {
StubElement stub = ((StubBasedPsiElement)root).getStub();
while (stub != null) {
m += "\n each stub=" + stub;
if (stub instanceof PsiFileStub) {
m += "; fileStub.psi=" + stub.getPsi() + "; reason=" + ((PsiFileStub)stub).getInvalidationReason();
}
stub = stub.getParentStub();
}
}
return m;
}
while (element != null && !(element instanceof PsiFile)) element = element.getParent();
PsiFile file = (PsiFile)element;
if (file == null) return "containing file is null";
FileViewProvider provider = file.getViewProvider();
VirtualFile vFile = provider.getVirtualFile();
if (!vFile.isValid()) return vFile + " is invalid";
if (!provider.isPhysical()) {
PsiElement context = file.getContext();
if (context != null && !context.isValid()) {
return "invalid context: " + reason(context);
}
}
PsiManager manager = file.getManager();
if (manager.getProject().isDisposed()) return "project is disposed";
Language language = file.getLanguage();
if (language != provider.getBaseLanguage()) return "File language:" + language + " != Provider base language:" + provider.getBaseLanguage();
FileViewProvider p = manager.findViewProvider(vFile);
if (provider != p) return "different providers: " + provider + "(" + id(provider) + "); " + p + "(" + id(p) + ")";
if (!provider.isPhysical()) return "non-physical provider: " + provider; // "dummy" file?
return "psi is outdated";
}