当前位置: 首页>>代码示例>>Java>>正文


Java PsiFileStub类代码示例

本文整理汇总了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);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:StubBuildingVisitor.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:PsiClassImpl.java

示例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);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:26,代码来源:StubBuildingVisitor.java

示例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;
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:23,代码来源:ClassFileStubBuilder.java

示例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));
		}
	}
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:27,代码来源:StubBuildingVisitor.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:JavaStubElementType.java

示例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();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:ClsRepositoryPsiElement.java

示例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());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:PsiClassImpl.java

示例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);
}
 
开发者ID:consulo,项目名称:consulo,代码行数:14,代码来源:SubstrateRef.java

示例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();
	}
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:9,代码来源:StubBuildingVisitor.java

示例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;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:31,代码来源:PsiClassImpl.java

示例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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:4,代码来源:ClsStubBuilderFactory.java

示例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();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:7,代码来源:StubBuildingVisitor.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:78,代码来源:RecordUtil.java

示例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";
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:49,代码来源:PsiInvalidElementAccessException.java


注:本文中的com.intellij.psi.stubs.PsiFileStub类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。