本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
示例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));
}
示例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));
}
}
示例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());
}
示例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);
}
示例13: getHomeDirectory
import com.intellij.openapi.vfs.StandardFileSystems; //导入依赖的package包/类
@Override
public VirtualFile getHomeDirectory() {
if (myHomePath == null) {
return null;
}
return StandardFileSystems.local().findFileByPath(myHomePath);
}
示例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;
}
});
}
示例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;
}