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


Java StandardFileSystems类代码示例

本文整理汇总了Java中com.intellij.openapi.vfs.StandardFileSystems的典型用法代码示例。如果您正苦于以下问题:Java StandardFileSystems类的具体用法?Java StandardFileSystems怎么用?Java StandardFileSystems使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


StandardFileSystems类属于com.intellij.openapi.vfs包,在下文中一共展示了StandardFileSystems类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: loadModuleInternal

import com.intellij.openapi.vfs.StandardFileSystems; //导入依赖的package包/类
@NotNull
private Module loadModuleInternal(@NotNull String filePath) throws ModuleWithNameAlreadyExists, IOException {
  filePath = resolveShortWindowsName(filePath);
  final VirtualFile moduleFile = StandardFileSystems.local().findFileByPath(filePath);
  if (moduleFile == null || !moduleFile.exists()) {
    throw new FileNotFoundException(ProjectBundle.message("module.file.does.not.exist.error", filePath));
  }

  String path = moduleFile.getPath();
  ModuleEx module = getModuleByFilePath(path);
  if (module == null) {
    ApplicationManager.getApplication().invokeAndWait(new Runnable() {
      @Override
      public void run() {
        moduleFile.refresh(false, false);
      }
    }, ModalityState.any());
    module = createAndLoadModule(path);
    initModule(module, path, null);
  }
  return module;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:ModuleManagerImpl.java

示例2: getUserSkeletonsDirectory

import com.intellij.openapi.vfs.StandardFileSystems; //导入依赖的package包/类
@Nullable
public static VirtualFile getUserSkeletonsDirectory() {
  if (ourUserSkeletonsDirectory == null) {
    for (String path : getPossibleUserSkeletonsPaths()) {
      ourUserSkeletonsDirectory = StandardFileSystems.local().findFileByPath(path);
      if (ourUserSkeletonsDirectory != null) {
        break;
      }
    }
  }
  if (!ourNoSkeletonsErrorReported && ourUserSkeletonsDirectory == null) {
    ourNoSkeletonsErrorReported = true;
    LOG.warn("python-skeletons directory not found in paths: " + getPossibleUserSkeletonsPaths());
  }
  return ourUserSkeletonsDirectory;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:PyUserSkeletonsUtil.java

示例3: findXmlFile

import com.intellij.openapi.vfs.StandardFileSystems; //导入依赖的package包/类
@Nullable
public static XmlFile findXmlFile(PsiFile base, @NotNull String uri) {
  PsiFile result = null;

  if (ApplicationManager.getApplication().isUnitTestMode()) {
    String data = base.getOriginalFile().getUserData(TEST_PATH);

    if (data != null) {
      String filePath = data + "/" + uri;
      final VirtualFile path = StandardFileSystems.local().findFileByPath(filePath.replace(File.separatorChar, '/'));
      if (path != null) {
        result = base.getManager().findFile(path);
      }
    }
  }
  if (result == null) {
    result = findRelativeFile(uri, base);
  }

  if (result instanceof XmlFile) {
    return (XmlFile)result;
  }

  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:XmlUtil.java

示例4: calcRoots

import com.intellij.openapi.vfs.StandardFileSystems; //导入依赖的package包/类
private static List<VirtualFile> calcRoots(@Nullable VirtualFile home) {
  if (home == null) {
    return Collections.emptyList();
  }

  final VirtualFile lib = home.findChild("lib");
  if (lib == null) {
    return Collections.emptyList();
  }

  List<VirtualFile> result = new ArrayList<VirtualFile>();
  for (VirtualFile file : lib.getChildren()) {
    if ("jar".equals(file.getExtension())) {
      ContainerUtil.addIfNotNull(StandardFileSystems.getJarRootForLocalFile(file), result);
    }
  }
  return result;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:SdkHomeSettings.java

示例5: pathToUrl

import com.intellij.openapi.vfs.StandardFileSystems; //导入依赖的package包/类
protected static String pathToUrl(File path) {
  String name = path.getName();
  boolean isJarFile =
      FileUtilRt.extensionEquals(name, "jar") || FileUtilRt.extensionEquals(name, "zip");
  // .jar files require an URL with "jar" protocol.
  String protocol =
      isJarFile
          ? StandardFileSystems.JAR_PROTOCOL
          : VirtualFileSystemProvider.getInstance().getSystem().getProtocol();
  String filePath = FileUtil.toSystemIndependentName(path.getPath());
  String url = VirtualFileManager.constructUrl(protocol, filePath);
  if (isJarFile) {
    url += URLUtil.JAR_SEPARATOR;
  }
  return url;
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:17,代码来源:BlazeLibrary.java

示例6: Unity3dProjectChangeListener

import com.intellij.openapi.vfs.StandardFileSystems; //导入依赖的package包/类
public Unity3dProjectChangeListener(@NotNull Project project, @NotNull StartupManager startupManager)
{
	myProject = project;

	for(Unity3dProjectSourceFileTypeFactory factory : Unity3dProjectSourceFileTypeFactory.EP_NAME.getExtensions())
	{
		factory.registerFileTypes(mySourceFileTypes::add);
	}

	myProject.getMessageBus().connect().subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootListener()
	{
		@Override
		@RequiredReadAction
		public void rootsChanged(ModuleRootEvent event)
		{
			checkAndRunIfNeed();
		}
	});

	VirtualFileManager.getInstance().addVirtualFileListener(this, this);

	myAssetsDirPointer = VirtualFilePointerManager.getInstance().create(StandardFileSystems.FILE_PROTOCOL_PREFIX + myProject.getPresentableUrl() + "/" + Unity3dProjectImportUtil
			.ASSETS_DIRECTORY, this, null);

	startupManager.registerPostStartupActivity(this::checkAndRunIfNeed);
}
 
开发者ID:consulo,项目名称:consulo-unity3d,代码行数:27,代码来源:Unity3dProjectChangeListener.java

示例7: newModule

import com.intellij.openapi.vfs.StandardFileSystems; //导入依赖的package包/类
@Override
@Nonnull
public Module newModule(@Nonnull @NonNls String name, @Nullable @NonNls String dirPath) {
  assertWritable();

  final String dirUrl = dirPath == null ? null : VirtualFileManager.constructUrl(StandardFileSystems.FILE_PROTOCOL, dirPath);

  ModuleEx moduleEx = null;
  if (dirUrl != null) {
    moduleEx = getModuleByDirUrl(dirUrl);
  }

  if (moduleEx == null) {
    moduleEx = createModule(name, dirUrl, null);
    initModule(moduleEx);
  }
  return moduleEx;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:19,代码来源:ModuleManagerImpl.java

示例8: testFindRootShouldNotBeFooledByRelativePath

import com.intellij.openapi.vfs.StandardFileSystems; //导入依赖的package包/类
public void testFindRootShouldNotBeFooledByRelativePath() throws IOException {
  File tmp = createTempDirectory();
  File x = new File(tmp, "x.jar");
  x.createNewFile();
  LocalFileSystem lfs = LocalFileSystem.getInstance();
  VirtualFile vx = lfs.refreshAndFindFileByIoFile(x);
  assertNotNull(vx);
  ArchiveFileSystem jfs = (ArchiveFileSystem)StandardFileSystems.jar();
  VirtualFile root = ArchiveVfsUtil.getArchiveRootForLocalFile(vx);

  PersistentFS fs = PersistentFS.getInstance();

  String path = vx.getPath() + "/../" + vx.getName() + ArchiveFileSystem.ARCHIVE_SEPARATOR;
  NewVirtualFile root1 = fs.findRoot(path, (NewVirtualFileSystem)jfs);

  assertSame(root1, root);
}
 
开发者ID:consulo,项目名称:consulo,代码行数:18,代码来源:PersistentFSTest.java

示例9: testDocumentReuse

import com.intellij.openapi.vfs.StandardFileSystems; //导入依赖的package包/类
public void testDocumentReuse() throws IOException {
  File classFile = new File(FileUtil.getTempDirectory(), "ReuseTest.class");
  FileUtil.writeToFile(classFile, "");
  VirtualFile vFile = StandardFileSystems.local().findFileByPath(classFile.getPath());
  assertNotNull(classFile.getPath(), vFile);
  PsiFile psiFile = PsiManager.getInstance(getProject()).findFile(vFile);
  assertNotNull(psiFile);
  String testDir = getTestDataDir();

  FileUtil.copy(new File(testDir, "pkg/ReuseTestV1.class"), classFile);
  vFile.refresh(false, false);
  PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
  String text1 = psiFile.getText();
  assertTrue(text1, text1.contains("private int f1"));
  assertFalse(text1, text1.contains("private int f2"));
  Document doc1 = FileDocumentManager.getInstance().getCachedDocument(vFile);
  assertNotNull(doc1);
  assertSame(doc1, PsiDocumentManager.getInstance(getProject()).getDocument(psiFile));

  FileUtil.copy(new File(testDir, "pkg/ReuseTestV2.class"), classFile);
  vFile.refresh(false, false);
  PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
  String text2 = psiFile.getText();
  assertTrue(text2, text2.contains("private int f1"));
  assertTrue(text2, text2.contains("private int f2"));
  Document doc2 = FileDocumentManager.getInstance().getCachedDocument(vFile);
  assertNotNull(doc2);
  assertSame(doc2, PsiDocumentManager.getInstance(getProject()).getDocument(psiFile));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:30,代码来源:ClsMirrorBuildingTest.java

示例10: testElementAt

import com.intellij.openapi.vfs.StandardFileSystems; //导入依赖的package包/类
public void testElementAt() {
  String path = getTestDataDir() + "/pkg/SimpleEnum.class";
  VirtualFile vFile = StandardFileSystems.local().findFileByPath(path);
  assertNotNull(path, vFile);
  PsiFile psiFile = PsiManager.getInstance(getProject()).findFile(vFile);
  assertNotNull(path, psiFile);
  for (int i = 0; i < psiFile.getTextLength(); i++) {
    PsiElement element = psiFile.findElementAt(i);
    assertTrue(i + ":" + element, element == null || element instanceof ClsElementImpl && !(element instanceof PsiFile));
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:ClsMirrorBuildingTest.java

示例11: doTest

import com.intellij.openapi.vfs.StandardFileSystems; //导入依赖的package包/类
private static void doTest(String clsPath, String txtPath) {
  VirtualFile file = (clsPath.contains("!/") ? StandardFileSystems.jar() : StandardFileSystems.local()).findFileByPath(clsPath);
  assertNotNull(clsPath, file);

  String expected;
  try {
    expected = StringUtil.trimTrailing(PlatformTestUtil.loadFileText(txtPath));
  }
  catch (IOException e) {
    throw new RuntimeException(e);
  }

  assertEquals(expected, ClsFileImpl.decompile(file).toString());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:ClsMirrorBuildingTest.java

示例12: canonicalizeUrl

import com.intellij.openapi.vfs.StandardFileSystems; //导入依赖的package包/类
protected Url canonicalizeUrl(@NotNull String url, @Nullable Url baseUrl, boolean trimFileScheme, int sourceIndex, boolean baseUrlIsFile) {
  if (trimFileScheme && url.startsWith(StandardFileSystems.FILE_PROTOCOL_PREFIX)) {
    return Urls.newLocalFileUrl(FileUtil.toCanonicalPath(VfsUtilCore.toIdeaUrl(url, true).substring(StandardFileSystems.FILE_PROTOCOL_PREFIX.length()), '/'));
  }
  else if (baseUrl == null || url.contains(URLUtil.SCHEME_SEPARATOR) || url.startsWith("data:") || url.startsWith("blob:") || url.startsWith("javascript:")) {
    return Urls.parseEncoded(url);
  }

  String path = canonicalizePath(url, baseUrl, baseUrlIsFile);
  if (baseUrl.getScheme() == null && baseUrl.isInLocalFileSystem()) {
    return Urls.newLocalFileUrl(path);
  }

  // browserify produces absolute path in the local filesystem
  if (isAbsolute(path)) {
    VirtualFile file = LocalFileFinder.findFile(path);
    if (file != null) {
      if (absoluteLocalPathToSourceIndex == null) {
        // must be linked, on iterate original path must be first
        absoluteLocalPathToSourceIndex = createStringIntMap(rawSources.size());
        sourceIndexToAbsoluteLocalPath = new String[rawSources.size()];
      }
      absoluteLocalPathToSourceIndex.put(path, sourceIndex);
      sourceIndexToAbsoluteLocalPath[sourceIndex] = path;
      String canonicalPath = file.getCanonicalPath();
      if (canonicalPath != null && !canonicalPath.equals(path)) {
        absoluteLocalPathToSourceIndex.put(canonicalPath, sourceIndex);
      }
      return Urls.newLocalFileUrl(path);
    }
  }
  return new UrlImpl(baseUrl.getScheme(), baseUrl.getAuthority(), path, null);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:34,代码来源:SourceResolver.java

示例13: getHomeDirectory

import com.intellij.openapi.vfs.StandardFileSystems; //导入依赖的package包/类
@Override
public VirtualFile getHomeDirectory() {
  if (myHomePath == null) {
    return null;
  }
  return StandardFileSystems.local().findFileByPath(myHomePath);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:ProjectJdkImpl.java

示例14: collectJarFiles

import com.intellij.openapi.vfs.StandardFileSystems; //导入依赖的package包/类
public static void collectJarFiles(final VirtualFile dir, final List<VirtualFile> container, final boolean recursively) {
  VfsUtilCore.visitChildrenRecursively(dir, new VirtualFileVisitor(SKIP_ROOT, recursively ? null : ONE_LEVEL_DEEP) {
    @Override
    public boolean visitFile(@NotNull VirtualFile file) {
      final VirtualFile jarRoot = file.isDirectory() ? null : StandardFileSystems.getJarRootForLocalFile(file);
      if (jarRoot != null) {
        container.add(jarRoot);
        return false;
      }
      return true;
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:LibraryImpl.java

示例15: fun

import com.intellij.openapi.vfs.StandardFileSystems; //导入依赖的package包/类
@Override
public VirtualFile fun(String s) {
  final FileType fileType = FileTypeRegistry.getInstance().getFileTypeByFileName(s);
  final VirtualFile localFile = PATH_TO_LOCAL_VFILE.fun(s);
  if (localFile == null) return null;

  if (ArchiveFileType.INSTANCE.equals(fileType) && !localFile.isDirectory()) {
    return StandardFileSystems.getJarRootForLocalFile(localFile);
  }
  return localFile;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:PathsList.java


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