Java 类com.intellij.psi.stubs.Stub 实例源码

项目:intellij-ce-playground    文件:DebugUtil.java   
public static void stubTreeToBuffer(final Stub node, final Appendable buffer, final int indent) {
  StringUtil.repeatSymbol(buffer, ' ', indent);
  try {
    final ObjectStubSerializer stubType = node.getStubType();
    if (stubType != null) {
      buffer.append(stubType.toString()).append(':');
    }
    buffer.append(node.toString()).append('\n');

    @SuppressWarnings({"unchecked"})
    final List<? extends Stub> children = node.getChildrenStubs();
    for (final Stub child : children) {
      stubTreeToBuffer(child, buffer, indent + 2);
    }
  }
  catch (IOException e) {
    LOG.error(e);
  }
}
项目:intellij-ce-playground    文件:DomServiceImpl.java   
@NotNull
private static XmlFileHeader calcXmlFileHeader(final XmlFile file) {

  if (file instanceof PsiFileEx && ((PsiFileEx)file).isContentsLoaded() && file.getNode().isParsed()) {
    return computeHeaderByPsi(file);
  }

  if (!XmlUtil.isStubBuilding() && file.getFileType() == XmlFileType.INSTANCE) {
    VirtualFile virtualFile = file.getVirtualFile();
    if (virtualFile instanceof VirtualFileWithId) {
      ObjectStubTree tree = StubTreeLoader.getInstance().readFromVFile(file.getProject(), virtualFile);
      if (tree != null) {
        Stub root = tree.getRoot();
        if (root instanceof FileStub) {
          return ((FileStub)root).getHeader();
        }
      }
    }
  }

  if (!file.isValid()) return XmlFileHeader.EMPTY;

  return NanoXmlUtil.parseHeader(file);
}
项目:tools-idea    文件:DebugUtil.java   
public static void stubTreeToBuffer(final Stub node, final Appendable buffer, final int indent) {
  StringUtil.repeatSymbol(buffer, ' ', indent);
  try {
    final ObjectStubSerializer stubType = node.getStubType();
    if (stubType != null) {
      buffer.append(stubType.toString()).append(':');
    }
    buffer.append(node.toString()).append('\n');

    @SuppressWarnings({"unchecked"})
    final List<? extends Stub> children = node.getChildrenStubs();
    for (final Stub child : children) {
      stubTreeToBuffer(child, buffer, indent + 2);
    }
  }
  catch (IOException e) {
    LOG.error(e);
  }
}
项目:consulo    文件:DebugUtil.java   
public static void stubTreeToBuffer(final Stub node, final Appendable buffer, final int indent) {
  StringUtil.repeatSymbol(buffer, ' ', indent);
  try {
    final ObjectStubSerializer stubType = node.getStubType();
    if (stubType != null) {
      buffer.append(stubType.toString()).append(':');
    }
    buffer.append(node.toString()).append('\n');

    @SuppressWarnings({"unchecked"}) final List<? extends Stub> children = node.getChildrenStubs();
    for (final Stub child : children) {
      stubTreeToBuffer(child, buffer, indent + 2);
    }
  }
  catch (IOException e) {
    LOG.error(e);
  }
}
项目:intellij-ce-playground    文件:DebugUtil.java   
public static String stubTreeToString(final Stub root) {
  final LengthBuilder ruler = new LengthBuilder();
  stubTreeToBuffer(root, ruler, 0);
  final StringBuilder builder = new StringBuilder(ruler.getLength());
  stubTreeToBuffer(root, builder, 0);
  return builder.toString();
}
项目:intellij-ce-playground    文件:DomStubBuilder.java   
@Override
public Stub buildStubTree(FileContent fileContent) {
  PsiFile psiFile = fileContent.getPsiFile();
  if (!(psiFile instanceof XmlFile)) return null;

  Document document = FileDocumentManager.getInstance().getCachedDocument(fileContent.getFile());
  Project project = fileContent.getProject();
  if (project == null) {
    project = psiFile.getProject();
  }
  if (document != null) {
    PsiFile existingPsi = PsiDocumentManager.getInstance(project).getPsiFile(document);
    if (existingPsi instanceof XmlFile) {
      psiFile = existingPsi;
    }
  }

  XmlFile xmlFile = (XmlFile)psiFile;
  try {
    XmlUtil.BUILDING_DOM_STUBS.set(Boolean.TRUE);
    DomFileElement<? extends DomElement> fileElement = DomManager.getDomManager(project).getFileElement(xmlFile);
    if (fileElement == null || !fileElement.getFileDescription().hasStubs()) return null;

    XmlFileHeader header = DomService.getInstance().getXmlFileHeader(xmlFile);
    if (header.getRootTagLocalName() == null) {
      LOG.error("null root tag for " + fileElement + " for " + fileContent.getFile());
    }
    FileStub fileStub = new FileStub(header);
    XmlTag rootTag = xmlFile.getRootTag();
    if (rootTag != null) {
      new DomStubBuilderVisitor(DomManagerImpl.getDomManager(project)).visitXmlElement(rootTag, fileStub, 0);
    }
    return fileStub;
  }
  finally {
    XmlUtil.BUILDING_DOM_STUBS.set(Boolean.FALSE);
    SemService.getSemService(project).clearCache();
  }
}
项目:tools-idea    文件:DebugUtil.java   
public static String stubTreeToString(final Stub root) {
  final LengthBuilder ruler = new LengthBuilder();
  stubTreeToBuffer(root, ruler, 0);
  final StringBuilder builder = new StringBuilder(ruler.getLength());
  stubTreeToBuffer(root, builder, 0);
  return builder.toString();
}
项目:tools-idea    文件:DomStubBuilder.java   
@Override
public Stub buildStubTree(FileContent fileContent) {
  VirtualFile file = fileContent.getFile();
  Project project = fileContent.getProject();
  PsiFile psiFile = PsiManager.getInstance(project).findFile(file);
  if (!(psiFile instanceof XmlFile)) return null;

  XmlFile xmlFile = (XmlFile)psiFile;
  try {
    XmlUtil.BUILDING_DOM_STUBS.set(Boolean.TRUE);
    psiFile.putUserData(CONTENT_FOR_DOM_STUBS, fileContent);
    DomFileElement<? extends DomElement> fileElement = DomManager.getDomManager(project).getFileElement(xmlFile);
    if (fileElement == null || !fileElement.getFileDescription().hasStubs()) return null;

    XmlFileHeader header = DomService.getInstance().getXmlFileHeader(xmlFile);
    if (header.getRootTagLocalName() == null) {
      LOG.error("null root tag for " + fileElement + " for " + file);
    }
    FileStub fileStub = new FileStub(header);
    DomStubBuilderVisitor visitor = new DomStubBuilderVisitor(fileStub);
    visitor.visitDomElement(fileElement.getRootElement());
    return fileStub;
  }
  finally {
    XmlUtil.BUILDING_DOM_STUBS.set(Boolean.FALSE);
    psiFile.putUserData(CONTENT_FOR_DOM_STUBS, null);
  }
}
项目:tools-idea    文件:DomServiceImpl.java   
@NotNull
private static XmlFileHeader calcXmlFileHeader(final XmlFile file) {

  if (file instanceof PsiFileEx && ((PsiFileEx)file).isContentsLoaded() && file.getNode().isParsed()) {
    return computeHeaderByPsi(file);
  }

  if (!XmlUtil.isStubBuilding() && file.getFileType() == XmlFileType.INSTANCE) {
    VirtualFile virtualFile = file.getVirtualFile();
    if (virtualFile instanceof VirtualFileWithId) {
      ObjectStubTree tree = StubTreeLoader.getInstance().readFromVFile(file.getProject(), virtualFile);
      if (tree != null) {
        Stub root = tree.getRoot();
        if (root instanceof FileStub) {
          return ((FileStub)root).getHeader();
        }
      }
    }
  }

  if (!file.isValid()) return XmlFileHeader.EMPTY;

  if (XmlUtil.isStubBuilding() && file.getFileType() == XmlFileType.INSTANCE) {
    FileContent fileContent = file.getUserData(DomStubBuilder.CONTENT_FOR_DOM_STUBS);
    if (fileContent != null) {
      //noinspection IOResourceOpenedButNotSafelyClosed
      return NanoXmlUtil.parseHeader(new CharSequenceReader(fileContent.getContentAsText()));
    }
  }
  return NanoXmlUtil.parseHeader(file);
}
项目:consulo    文件:DebugUtil.java   
public static String stubTreeToString(final Stub root) {
  final LengthBuilder ruler = new LengthBuilder();
  stubTreeToBuffer(root, ruler, 0);
  final StringBuilder builder = new StringBuilder(ruler.getLength());
  stubTreeToBuffer(root, builder, 0);
  return builder.toString();
}
项目:consulo    文件:AstPath.java   
@Nullable
@Override
public Stub getStub(int stubIndex) {
  if (stubIndex < 0) return null;

  StubTree stubTree = getFileStubTree();
  return stubTree == null ? null : stubTree.getPlainList().get(stubIndex);
}
项目:consulo    文件:AstPath.java   
@Nullable
@Override
public Stub getGreenStub(int stubIndex) {
  if (stubIndex < 0) return null;

  StubTree stubTree = getContainingFile().getGreenStubTree();
  return stubTree == null ? null : stubTree.getPlainList().get(stubIndex);
}
项目:consulo-xml    文件:DomServiceImpl.java   
@NotNull
private static XmlFileHeader calcXmlFileHeader(final XmlFile file) {

  if (file instanceof PsiFileEx && ((PsiFileEx)file).isContentsLoaded() && file.getNode().isParsed()) {
    return computeHeaderByPsi(file);
  }

  if (!XmlUtil.isStubBuilding() && file.getFileType() == XmlFileType.INSTANCE) {
    VirtualFile virtualFile = file.getVirtualFile();
    if (virtualFile instanceof VirtualFileWithId) {
      ObjectStubTree tree = StubTreeLoader.getInstance().readFromVFile(file.getProject(), virtualFile);
      if (tree != null) {
        Stub root = tree.getRoot();
        if (root instanceof FileStub) {
          return ((FileStub)root).getHeader();
        }
      }
    }
  }

  if (!file.isValid()) return XmlFileHeader.EMPTY;

  if (XmlUtil.isStubBuilding() && file.getFileType() == XmlFileType.INSTANCE) {
    FileContent fileContent = file.getUserData(DomStubBuilder.CONTENT_FOR_DOM_STUBS);
    if (fileContent != null) {
      //noinspection IOResourceOpenedButNotSafelyClosed
      return NanoXmlUtil.parseHeader(new CharSequenceReader(fileContent.getContentAsText()));
    }
  }
  return NanoXmlUtil.parseHeader(file);
}
项目:intellij-ce-playground    文件:FileStub.java   
@Nullable
public ElementStub getRootTagStub() {
  List<? extends Stub> stubs = getChildrenStubs();
  return stubs.isEmpty() ? null : (ElementStub)stubs.get(0);
}
项目:intellij    文件:ProjectViewFileStubBuilder.java   
@Nullable
@Override
public Stub buildStubTree(FileContent fileContent) {
  return null;
}
项目:intellij    文件:BuildFileStubBuilder.java   
@Nullable
@Override
public Stub buildStubTree(FileContent fileContent) {
  return null;
}
项目:tools-idea    文件:FileStub.java   
@Nullable
public ElementStub getRootTagStub() {
  List<? extends Stub> stubs = getChildrenStubs();
  return stubs.isEmpty() ? null : (ElementStub)stubs.get(0);
}
项目:buck    文件:BuckFileUtil.java   
public static void setBuckFileType() {
  ApplicationManager.getApplication()
      .runWriteAction(
          new Runnable() {
            @Override
            public void run() {
              FileTypeManager fileTypeManager = FileTypeManagerImpl.getInstance();

              FileType fileType =
                  fileTypeManager.getFileTypeByFileName(
                      BuckFileType.INSTANCE.getDefaultExtension());

              // Remove all FileType associations for BUCK files that are not BuckFileType
              while (!(fileType instanceof BuckFileType || fileType instanceof UnknownFileType)) {
                List<FileNameMatcher> fileNameMatchers =
                    fileTypeManager.getAssociations(fileType);

                for (FileNameMatcher fileNameMatcher : fileNameMatchers) {
                  if (fileNameMatcher.accept(BuckFileType.INSTANCE.getDefaultExtension())) {
                    fileTypeManager.removeAssociation(fileType, fileNameMatcher);
                  }
                }

                fileType =
                    fileTypeManager.getFileTypeByFileName(
                        BuckFileType.INSTANCE.getDefaultExtension());
              }

              // Use a simple BinaryFileStubBuilder, that doesn't offer stubbing
              BinaryFileStubBuilders.INSTANCE.addExplicitExtension(
                  fileType,
                  new BinaryFileStubBuilder() {
                    @Override
                    public boolean acceptsFile(VirtualFile virtualFile) {
                      return false;
                    }

                    @Nullable
                    @Override
                    public Stub buildStubTree(FileContent fileContent) {
                      return null;
                    }

                    @Override
                    public int getStubVersion() {
                      return 0;
                    }
                  });
            }
          });
}
项目:consulo    文件:SubstrateRef.java   
@Nullable
public Stub getStub(int stubIndex) {
  return null;
}
项目:consulo    文件:SubstrateRef.java   
@Nullable
public Stub getGreenStub(int index) {
  return getStub(index);
}
项目:consulo    文件:SubstrateRef.java   
@Nonnull
@Override
public Stub getStub(int stubIndex) {
  return myStub;
}
项目:consulo-xml    文件:FileStubSerializer.java   
@NotNull
@Override
public FileStub deserialize(@NotNull StubInputStream dataStream, Stub parentStub) throws IOException
{
    return new FileStub(dataStream.readName(), dataStream.readName(), dataStream.readName(), dataStream.readName());
}
项目:consulo-xml    文件:FileStub.java   
@Nullable
public ElementStub getRootTagStub()
{
    List<? extends Stub> stubs = getChildrenStubs();
    return stubs.isEmpty() ? null : (ElementStub) stubs.get(0);
}
项目:consulo-xml    文件:DomStubBuilder.java   
@Override
public Stub buildStubTree(FileContent fileContent)
{
    VirtualFile file = fileContent.getFile();
    Project project = fileContent.getProject();
    PsiFile psiFile = PsiManager.getInstance(project).findFile(file);
    if(!(psiFile instanceof XmlFile))
    {
        return null;
    }

    XmlFile xmlFile = (XmlFile) psiFile;
    try
    {
        XmlUtil.BUILDING_DOM_STUBS.set(Boolean.TRUE);
        psiFile.putUserData(CONTENT_FOR_DOM_STUBS, fileContent);
        DomFileElement<? extends DomElement> fileElement = DomManager.getDomManager(project).getFileElement(xmlFile);
        if(fileElement == null || !fileElement.getFileDescription().hasStubs())
        {
            return null;
        }

        XmlFileHeader header = DomService.getInstance().getXmlFileHeader(xmlFile);
        if(header.getRootTagLocalName() == null)
        {
            LOG.error("null root tag for " + fileElement + " for " + file);
        }
        FileStub fileStub = new FileStub(header);
        XmlTag rootTag = xmlFile.getRootTag();
        if(rootTag != null)
        {
            new DomStubBuilderVisitor(DomManagerImpl.getDomManager(project)).visitXmlElement(rootTag, fileStub, 0);
        }
        return fileStub;
    }
    finally
    {
        XmlUtil.BUILDING_DOM_STUBS.set(Boolean.FALSE);
        psiFile.putUserData(CONTENT_FOR_DOM_STUBS, null);
    }
}