Java 类com.intellij.psi.impl.java.stubs.impl.PsiJavaFileStubImpl 实例源码

项目:intellij-ce-playground    文件:JavaLightStubBuilder.java   
@NotNull
@Override
protected StubElement createStubForFile(@NotNull PsiFile file, @NotNull LighterAST tree) {
  if (!(file instanceof PsiJavaFile)) {
    return super.createStubForFile(file, tree);
  }

  String refText = "";
  LighterASTNode pkg = LightTreeUtil.firstChildOfType(tree, tree.getRoot(), JavaElementType.PACKAGE_STATEMENT);
  if (pkg != null) {
    LighterASTNode ref = LightTreeUtil.firstChildOfType(tree, pkg, JavaElementType.JAVA_CODE_REFERENCE);
    if (ref != null) {
      refText = JavaSourceUtil.getReferenceText(tree, ref);
    }
  }
  return new PsiJavaFileStubImpl((PsiJavaFile)file, StringRef.fromString(refText), false);
}
项目:tools-idea    文件:ClsFileImpl.java   
@Override
@NotNull
public StubTree getStubTree() {
  ApplicationManager.getApplication().assertReadAccessAllowed();

  StubTree stubTree = dereference(myStub);
  if (stubTree != null) return stubTree;

  synchronized (myStubLock) {
    stubTree = dereference(myStub);
    if (stubTree != null) return stubTree;

    stubTree = (StubTree)StubTreeLoader.getInstance().readOrBuild(getProject(), getVirtualFile(), this);
    if (stubTree == null) {
      LOG.warn("No stub for class file in index: " + getVirtualFile().getPresentableUrl());
      stubTree = new StubTree(new PsiJavaFileStubImpl("corrupted.classfiles", true));
    }
    //noinspection unchecked
    ((PsiFileStubImpl)stubTree.getRoot()).setPsi(this);

    myStub = new SoftReference<StubTree>(stubTree);
  }

  return stubTree;
}
项目:tools-idea    文件:JavaLightStubBuilder.java   
@NotNull
@Override
protected StubElement createStubForFile(@NotNull PsiFile file, @NotNull LighterAST tree) {
  if (!(file instanceof PsiJavaFile)) {
    return super.createStubForFile(file, tree);
  }

  String refText = "";
  LighterASTNode pkg = LightTreeUtil.firstChildOfType(tree, tree.getRoot(), JavaElementType.PACKAGE_STATEMENT);
  if (pkg != null) {
    LighterASTNode ref = LightTreeUtil.firstChildOfType(tree, pkg, JavaElementType.JAVA_CODE_REFERENCE);
    if (ref != null) {
      refText = SourceUtil.getReferenceText(tree, ref);
    }
  }
  return new PsiJavaFileStubImpl((PsiJavaFile)file, StringRef.fromString(refText), false);
}
项目:consulo-java    文件:JavaLightStubBuilder.java   
@NotNull
@Override
protected StubElement createStubForFile(@NotNull PsiFile file, @NotNull LighterAST tree)
{
    if(!(file instanceof PsiJavaFile))
    {
        return super.createStubForFile(file, tree);
    }

    String refText = "";
    LighterASTNode pkg = LightTreeUtil.firstChildOfType(tree, tree.getRoot(), JavaElementType.PACKAGE_STATEMENT);
    if(pkg != null)
    {
        LighterASTNode ref = LightTreeUtil.firstChildOfType(tree, pkg, JavaElementType.JAVA_CODE_REFERENCE);
        if(ref != null)
        {
            refText = JavaSourceUtil.getReferenceText(tree, ref);
        }
    }
    return new PsiJavaFileStubImpl((PsiJavaFile) file, refText, null, false);
}
项目:intellij-ce-playground    文件:ClsFileImpl.java   
@Override
@NotNull
public StubTree getStubTree() {
  ApplicationManager.getApplication().assertReadAccessAllowed();

  StubTree stubTree = dereference(myStub);
  if (stubTree != null) return stubTree;

  // build newStub out of lock to avoid deadlock
  StubTree newStubTree = (StubTree)StubTreeLoader.getInstance().readOrBuild(getProject(), getVirtualFile(), this);
  if (newStubTree == null) {
    if (LOG.isDebugEnabled()) {
      LOG.debug("No stub for class file in index: " + getVirtualFile().getPresentableUrl());
    }
    newStubTree = new StubTree(new PsiJavaFileStubImpl("corrupted_class_files", true));
  }

  synchronized (myStubLock) {
    stubTree = dereference(myStub);
    if (stubTree != null) return stubTree;

    stubTree = newStubTree;

    @SuppressWarnings("unchecked") PsiFileStubImpl<PsiFile> fileStub = (PsiFileStubImpl)stubTree.getRoot();
    fileStub.setPsi(this);

    myStub = new SoftReference<StubTree>(stubTree);
  }

  return stubTree;
}
项目:intellij-ce-playground    文件:JavaFileElementType.java   
@NotNull
@Override
public PsiJavaFileStub deserialize(@NotNull final StubInputStream dataStream, final StubElement parentStub) throws IOException {
  boolean compiled = dataStream.readBoolean();
  StringRef packName = dataStream.readName();
  return new PsiJavaFileStubImpl(null, packName, compiled);
}
项目:tools-idea    文件:JavaFileElementType.java   
@NotNull
@Override
public PsiJavaFileStub deserialize(@NotNull final StubInputStream dataStream, final StubElement parentStub) throws IOException {
  boolean compiled = dataStream.readBoolean();
  StringRef packName = dataStream.readName();
  return new PsiJavaFileStubImpl(null, packName, compiled);
}
项目:consulo-java    文件:JavaFileElementType.java   
@NotNull
@Override
public PsiJavaFileStub deserialize(@NotNull StubInputStream dataStream, StubElement parentStub) throws IOException
{
    boolean compiled = dataStream.readBoolean();
    int level = dataStream.readByte();
    StringRef packageName = dataStream.readName();
    return new PsiJavaFileStubImpl(null, StringRef.toString(packageName), level >= 0 ? LanguageLevel.values()[level] : null, compiled);
}