Java 类com.intellij.openapi.vfs.newvfs.impl.StubVirtualFile 实例源码

项目:intellij-kubernetes    文件:KubernetesYamlFileType.java   
@SuppressWarnings("ConstantConditions")
@Override
public boolean isMyFileType(@NotNull final VirtualFile file) {
    if (file instanceof StubVirtualFile) {
        return false; // Helps New -> File get correct file type
    }

    return recursionGuard.doPreventingRecursion(GUARD_ID, true, () -> {
        if (file.isValid()) {
            final String extension = file.getExtension();
            if ("yml".equalsIgnoreCase(extension) || "yaml".equalsIgnoreCase(extension)) {
                try (InputStream inputStream = file.getInputStream()) {
                    final byte[] bytes = new byte[BYTES_TO_READ];
                    final int n = inputStream.read(bytes, 0, BYTES_TO_READ);
                    return n > 0 && isKubernetesYaml(bytes);
                } catch (final IOException e) {
                    logger.info("Error while determining file type.", e);
                }
            }
        }
        return false;
    });
}
项目:intellij-ce-playground    文件:FileTypeManagerImpl.java   
@Override
@NotNull
public FileType getFileTypeByFile(@NotNull VirtualFile file) {
  FileType fileType = getOrDetectByFile(file);

  if (fileType == null) {
    fileType = file instanceof StubVirtualFile ? UnknownFileType.INSTANCE : getOrDetectFromContent(file);
  }

  return fileType;
}
项目:intellij    文件:BlazeResolveConfigurationEquivalenceTest.java   
private VirtualFile createVirtualFile(String path) {
  VirtualFile stub =
      new StubVirtualFile() {
        @Override
        public boolean isValid() {
          return true;
        }
      };
  when(mockFileSystem.findFileByIoFile(new File(path))).thenReturn(stub);
  return stub;
}
项目:consulo    文件:FileTypeManagerImpl.java   
@Override
@Nonnull
public FileType getFileTypeByFile(@Nonnull VirtualFile file) {
  FileType fileType = getOrDetectByFile(file);

  if (fileType == null) {
    fileType = file instanceof StubVirtualFile ? UnknownFileType.INSTANCE : getOrDetectFromContent(file);
  }

  return fileType;
}