本文整理汇总了Java中com.intellij.openapi.vfs.newvfs.impl.VirtualDirectoryImpl类的典型用法代码示例。如果您正苦于以下问题:Java VirtualDirectoryImpl类的具体用法?Java VirtualDirectoryImpl怎么用?Java VirtualDirectoryImpl使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
VirtualDirectoryImpl类属于com.intellij.openapi.vfs.newvfs.impl包,在下文中一共展示了VirtualDirectoryImpl类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: findContainingExtension
import com.intellij.openapi.vfs.newvfs.impl.VirtualDirectoryImpl; //导入依赖的package包/类
/**
* Traverses the given directories and returns the first valid
* extension definition that's applicable.
*
* @param directories List of directories to analyze
*/
public static TYPO3ExtensionDefinition findContainingExtension(PsiDirectory[] directories) {
for (PsiDirectory directory : directories) {
VirtualDirectoryImpl virtualFile = (VirtualDirectoryImpl) directory.getVirtualFile();
while (!isExtensionRootDirectory(virtualFile)) {
if (virtualFile.getParent() == null) {
return null;
}
virtualFile = virtualFile.getParent();
}
TYPO3ExtensionDefinition extensionDefinition = ExtensionDefinitionFactory.fromDirectory(virtualFile);
if (extensionDefinition != null) {
return extensionDefinition;
}
}
return null;
}
开发者ID:cedricziel,项目名称:idea-php-typo3-plugin,代码行数:27,代码来源:TYPO3ExtensionUtil.java
示例2: isExtensionRootDirectory
import com.intellij.openapi.vfs.newvfs.impl.VirtualDirectoryImpl; //导入依赖的package包/类
/**
* Determines if a directory is the top-most directory of an extension.
* It does so by searching the "ext_emconf.php"
*
* @param virtualFile Directory to scan
* @return true if the current directory is a root directory.
*/
private static boolean isExtensionRootDirectory(VirtualDirectoryImpl virtualFile) {
VirtualFile[] immediateChildren = virtualFile.getChildren();
for (VirtualFile file : immediateChildren) {
if (file.getName().equals("ext_emconf.php")) {
return true;
}
}
return false;
}
开发者ID:cedricziel,项目名称:idea-php-typo3-plugin,代码行数:17,代码来源:TYPO3ExtensionUtil.java
示例3: fromDirectory
import com.intellij.openapi.vfs.newvfs.impl.VirtualDirectoryImpl; //导入依赖的package包/类
public static TYPO3ExtensionDefinition fromDirectory(VirtualDirectoryImpl virtualDirectory) {
TYPO3ExtensionDefinition extensionDefinition = null;
// try finding composer manifest
VirtualFileSystemEntry composerManifest = virtualDirectory.findChild("composer.json");
if (composerManifest != null) {
try {
extensionDefinition = fromComposerManifest(composerManifest);
} catch (IOException e) {
e.printStackTrace();
}
}
return extensionDefinition != null ? extensionDefinition : null;
}
开发者ID:cedricziel,项目名称:idea-php-typo3-plugin,代码行数:16,代码来源:ExtensionDefinitionFactory.java
示例4: addSubTree
import com.intellij.openapi.vfs.newvfs.impl.VirtualDirectoryImpl; //导入依赖的package包/类
private static void addSubTree(VirtualFile root, Set<VirtualFile> to) {
if (root instanceof VirtualDirectoryImpl) {
for (VirtualFile child : ((VirtualDirectoryImpl)root).getCachedChildren()) {
if (child instanceof VirtualDirectoryImpl) {
to.add(child);
addSubTree(child, to);
}
}
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:PlatformTestCase.java
示例5: testFileCaseChange
import com.intellij.openapi.vfs.newvfs.impl.VirtualDirectoryImpl; //导入依赖的package包/类
public void testFileCaseChange() throws Exception {
if (SystemInfo.isFileSystemCaseSensitive) {
System.err.println("Ignored: case-insensitive FS required");
return;
}
File top = createTempDirectory(false);
File file = IoTestUtil.createTestFile(top, "file.txt", "test");
VirtualFile topDir = myFS.refreshAndFindFileByIoFile(top);
assertNotNull(topDir);
VirtualFile sourceFile = myFS.refreshAndFindFileByIoFile(file);
assertNotNull(sourceFile);
String newName = StringUtil.capitalize(file.getName());
FileUtil.rename(file, newName);
topDir.refresh(false, true);
assertFalse(((VirtualDirectoryImpl)topDir).allChildrenLoaded());
assertTrue(sourceFile.isValid());
assertEquals(newName, sourceFile.getName());
topDir.getChildren();
newName = newName.toLowerCase(Locale.ENGLISH);
FileUtil.rename(file, newName);
topDir.refresh(false, true);
assertTrue(((VirtualDirectoryImpl)topDir).allChildrenLoaded());
assertTrue(sourceFile.isValid());
assertEquals(newName, sourceFile.getName());
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:30,代码来源:LocalFileSystemTest.java
示例6: openFirstTask
import com.intellij.openapi.vfs.newvfs.impl.VirtualDirectoryImpl; //导入依赖的package包/类
public static void openFirstTask(@NotNull final Course course, @NotNull final Project project) {
LocalFileSystem.getInstance().refresh(false);
final Lesson firstLesson = StudyUtils.getFirst(course.getLessons());
final Task firstTask = StudyUtils.getFirst(firstLesson.getTaskList());
final VirtualFile taskDir = firstTask.getTaskDir(project);
if (taskDir == null) return;
final Map<String, TaskFile> taskFiles = firstTask.getTaskFiles();
VirtualFile activeVirtualFile = null;
for (Map.Entry<String, TaskFile> entry : taskFiles.entrySet()) {
final String name = entry.getKey();
final TaskFile taskFile = entry.getValue();
final VirtualFile virtualFile = ((VirtualDirectoryImpl)taskDir).refreshAndFindChild(name);
if (virtualFile != null) {
FileEditorManager.getInstance(project).openFile(virtualFile, true);
if (!taskFile.getAnswerPlaceholders().isEmpty()) {
activeVirtualFile = virtualFile;
}
}
}
if (activeVirtualFile != null) {
final PsiFile file = PsiManager.getInstance(project).findFile(activeVirtualFile);
ProjectView.getInstance(project).select(file, activeVirtualFile, true);
FileEditorManager.getInstance(project).openFile(activeVirtualFile, true);
} else {
String first = StudyUtils.getFirst(taskFiles.keySet());
if (first != null) {
NewVirtualFile firstFile = ((VirtualDirectoryImpl)taskDir).refreshAndFindChild(first);
if (firstFile != null) {
FileEditorManager.getInstance(project).openFile(firstFile, true);
}
}
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:34,代码来源:StudyProjectGenerator.java
示例7: getAllFilesInDirectory
import com.intellij.openapi.vfs.newvfs.impl.VirtualDirectoryImpl; //导入依赖的package包/类
public static List<String> getAllFilesInDirectory(VirtualFile directory, String target, String replacement) {
List<String> files = new ArrayList<String>();
VirtualFile[] children = directory.getChildren();
for (VirtualFile child : children) {
if (child instanceof VirtualDirectoryImpl) {
files.addAll(getAllFilesInDirectory(child, target, replacement));
} else if (child instanceof VirtualFileImpl) {
files.add(child.getPath().replace(target, replacement));
}
}
return files;
}
开发者ID:henjue,项目名称:vue-for-idea,代码行数:13,代码来源:FileUtils.java
示例8: testWindowsHiddenDirectory
import com.intellij.openapi.vfs.newvfs.impl.VirtualDirectoryImpl; //导入依赖的package包/类
public void testWindowsHiddenDirectory() throws Exception {
if (!SystemInfo.isWindows) {
System.err.println(getName() + " skipped: " + SystemInfo.OS_NAME);
return;
}
File file = new File("C:\\Documents and Settings\\desktop.ini");
if (!file.exists()) {
System.err.println(getName() + " skipped: missing " + file);
return;
}
String parent = FileUtil.toSystemIndependentName(file.getParent());
VirtualDirectoryImpl.allowRootAccess(parent);
try {
VirtualFile virtualFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(file);
assertNotNull(virtualFile);
NewVirtualFileSystem fs = (NewVirtualFileSystem)virtualFile.getFileSystem();
FileAttributes attributes = fs.getAttributes(virtualFile);
assertNotNull(attributes);
assertEquals(FileAttributes.Type.FILE, attributes.type);
assertEquals(FileAttributes.HIDDEN, attributes.flags);
}
finally {
VirtualDirectoryImpl.disallowRootAccess(parent);
}
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:29,代码来源:LocalFileSystemTest.java
示例9: testFileCaseChange
import com.intellij.openapi.vfs.newvfs.impl.VirtualDirectoryImpl; //导入依赖的package包/类
public void testFileCaseChange() throws Exception {
if (SystemInfo.isFileSystemCaseSensitive) {
System.err.println("Ignored: case-insensitive FS required");
return;
}
File top = createTempDirectory(false);
File file = IoTestUtil.createTestFile(top, "file.txt", "test");
File intermediate = new File(top, "_intermediate_");
VirtualFile topDir = myFS.refreshAndFindFileByIoFile(top);
assertNotNull(topDir);
VirtualFile sourceFile = myFS.refreshAndFindFileByIoFile(file);
assertNotNull(sourceFile);
String newName = StringUtil.capitalize(file.getName());
FileUtil.rename(file, intermediate);
FileUtil.rename(intermediate, new File(top, newName));
topDir.refresh(false, true);
assertFalse(((VirtualDirectoryImpl)topDir).allChildrenLoaded());
assertTrue(sourceFile.isValid());
assertEquals(newName, sourceFile.getName());
topDir.getChildren();
newName = newName.toLowerCase(Locale.ENGLISH);
FileUtil.rename(file, intermediate);
FileUtil.rename(intermediate, new File(top, newName));
topDir.refresh(false, true);
assertTrue(((VirtualDirectoryImpl)topDir).allChildrenLoaded());
assertTrue(sourceFile.isValid());
assertEquals(newName, sourceFile.getName());
}
开发者ID:consulo,项目名称:consulo,代码行数:33,代码来源:LocalFileSystemTest.java
示例10: openFirstTask
import com.intellij.openapi.vfs.newvfs.impl.VirtualDirectoryImpl; //导入依赖的package包/类
public static void openFirstTask(@NotNull final Course course, @NotNull final Project project) {
LocalFileSystem.getInstance().refresh(false);
final Lesson firstLesson = getFirst(course.getLessons());
if (firstLesson == null) return;
final Task firstTask = getFirst(firstLesson.getTaskList());
if (firstTask == null) return;
final VirtualFile taskDir = firstTask.getTaskDir(project);
if (taskDir == null) return;
final Map<String, TaskFile> taskFiles = firstTask.getTaskFiles();
VirtualFile activeVirtualFile = null;
for (Map.Entry<String, TaskFile> entry : taskFiles.entrySet()) {
final String relativePath = entry.getKey();
final TaskFile taskFile = entry.getValue();
taskDir.refresh(false, true);
final VirtualFile virtualFile = taskDir.findFileByRelativePath(relativePath);
if (virtualFile != null) {
if (!taskFile.getActivePlaceholders().isEmpty()) {
activeVirtualFile = virtualFile;
}
}
}
if (activeVirtualFile != null) {
final PsiFile file = PsiManager.getInstance(project).findFile(activeVirtualFile);
ProjectView.getInstance(project).select(file, activeVirtualFile, false);
final FileEditor[] editors = FileEditorManager.getInstance(project).openFile(activeVirtualFile, true);
if (editors.length == 0) {
return;
}
final FileEditor studyEditor = editors[0];
if (studyEditor instanceof StudyEditor) {
selectFirstAnswerPlaceholder((StudyEditor)studyEditor, project);
}
FileEditorManager.getInstance(project).openFile(activeVirtualFile, true);
}
else {
String first = getFirst(taskFiles.keySet());
if (first != null) {
NewVirtualFile firstFile = ((VirtualDirectoryImpl)taskDir).refreshAndFindChild(first);
if (firstFile != null) {
FileEditorManager.getInstance(project).openFile(firstFile, true);
}
}
}
}
开发者ID:medvector,项目名称:educational-plugin,代码行数:45,代码来源:StudyUtils.java
示例11: processQueue
import com.intellij.openapi.vfs.newvfs.impl.VirtualDirectoryImpl; //导入依赖的package包/类
private void processQueue(NewVirtualFileSystem fs, PersistentFS persistence) throws RefreshCancelledException {
TObjectHashingStrategy<String> strategy = FilePathHashingStrategy.create(fs.isCaseSensitive());
while (!myRefreshQueue.isEmpty()) {
Pair<NewVirtualFile, FileAttributes> pair = myRefreshQueue.pullFirst();
NewVirtualFile file = pair.first;
boolean fileDirty = file.isDirty();
debug(LOG, "file=%s dirty=%b", file, fileDirty);
if (!fileDirty) continue;
checkCancelled(file);
FileAttributes attributes = pair.second != null ? pair.second : fs.getAttributes(file);
if (attributes == null) {
scheduleDeletion(file);
continue;
}
NewVirtualFile parent = file.getParent();
if (parent != null && checkAndScheduleFileTypeChange(parent, file, attributes)) {
// ignore everything else
file.markClean();
continue ;
}
if (file.isDirectory()) {
boolean fullSync = ((VirtualDirectoryImpl)file).allChildrenLoaded();
if (fullSync) {
fullDirRefresh(fs, persistence, strategy, (VirtualDirectoryImpl)file);
}
else {
partialDirRefresh(fs, strategy, (VirtualDirectoryImpl)file);
}
}
else {
long currentTimestamp = persistence.getTimeStamp(file);
long upToDateTimestamp = attributes.lastModified;
long currentLength = persistence.getLastRecordedLength(file);
long upToDateLength = attributes.length;
if (currentTimestamp != upToDateTimestamp || currentLength != upToDateLength) {
scheduleUpdateContent(file);
}
}
boolean currentWritable = persistence.isWritable(file);
boolean upToDateWritable = attributes.isWritable();
if (LOG_ATTRIBUTES.isDebugEnabled()) {
LOG_ATTRIBUTES.debug("file=" + file + " writable vfs=" + file.isWritable() + " persistence=" + currentWritable + " real=" + upToDateWritable);
}
if (currentWritable != upToDateWritable) {
scheduleAttributeChange(file, VirtualFile.PROP_WRITABLE, currentWritable, upToDateWritable);
}
if (SystemInfo.isWindows) {
boolean currentHidden = file.is(VFileProperty.HIDDEN);
boolean upToDateHidden = attributes.isHidden();
if (currentHidden != upToDateHidden) {
scheduleAttributeChange(file, VirtualFile.PROP_HIDDEN, currentHidden, upToDateHidden);
}
}
if (attributes.isSymLink()) {
String currentTarget = file.getCanonicalPath();
String upToDateTarget = fs.resolveSymLink(file);
String upToDateVfsTarget = upToDateTarget != null ? FileUtil.toSystemIndependentName(upToDateTarget) : null;
if (!Comparing.equal(currentTarget, upToDateVfsTarget)) {
scheduleAttributeChange(file, VirtualFile.PROP_SYMLINK_TARGET, currentTarget, upToDateVfsTarget);
}
}
if (myIsRecursive || !file.isDirectory()) {
file.markClean();
}
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:77,代码来源:RefreshWorker.java
示例12: findFileById
import com.intellij.openapi.vfs.newvfs.impl.VirtualDirectoryImpl; //导入依赖的package包/类
@Nullable
private VirtualFileSystemEntry findFileById(int id, boolean cachedOnly, TIntArrayList visited, int mask) {
VirtualFileSystemEntry cached = myIdToDirCache.get(id);
if (cached != null) return cached;
if (visited != null && (visited.size() >= DEPTH_LIMIT || (mask & id) == id && visited.contains(id))) {
@NonNls String sb = "Dead loop detected in persistent FS (id=" + id + " cached-only=" + cachedOnly + "):";
for (int i = 0; i < visited.size(); i++) {
int _id = visited.get(i);
sb += "\n " + _id + " '" + getName(_id) + "' " +
String.format("%02x", getFileAttributes(_id)) + ' ' + myIdToDirCache.containsKey(_id);
}
LOG.error(sb);
return null;
}
if (visited == null) visited = new TIntArrayList(DEPTH_LIMIT);
visited.add(id);
int parentId = getParent(id);
VirtualFileSystemEntry result;
if (parentId == 0) {
myRootsLock.readLock().lock();
try {
result = myRootsById.get(id);
}
finally {
myRootsLock.readLock().unlock();
}
}
else {
VirtualFileSystemEntry parentFile = findFileById(parentId, cachedOnly, visited, mask |= id);
if (parentFile instanceof VirtualDirectoryImpl) {
result = ((VirtualDirectoryImpl)parentFile).findChildById(id, cachedOnly);
}
else {
result = null;
}
}
if (result != null && result.isDirectory()) {
VirtualFileSystemEntry old = myIdToDirCache.put(id, result);
if (old != null) result = old;
}
return result;
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:46,代码来源:PersistentFSImpl.java
示例13: testSubst
import com.intellij.openapi.vfs.newvfs.impl.VirtualDirectoryImpl; //导入依赖的package包/类
public void testSubst() throws Exception {
if (!SystemInfo.isWindows) {
System.err.println("Ignored: Windows required");
return;
}
File targetDir = createTestDir("top");
File subDir = createTestDir(targetDir, "sub");
File file = createTestFile(subDir, "test.txt");
File rootFile = createSubst(targetDir.getAbsolutePath());
VirtualDirectoryImpl.allowRootAccess(rootFile.getPath());
VirtualFile vfsRoot = myFileSystem.findFileByIoFile(rootFile);
try {
assertNotNull(rootFile.getPath(), vfsRoot);
File substDir = new File(rootFile, subDir.getName());
File substFile = new File(substDir, file.getName());
refresh(targetDir);
refresh(substDir);
LocalFileSystem.WatchRequest request = watch(substDir);
try {
myAccept = true;
FileUtil.writeToFile(file, "new content");
assertEvent(VFileContentChangeEvent.class, substFile.getAbsolutePath());
LocalFileSystem.WatchRequest request2 = watch(targetDir);
try {
myAccept = true;
FileUtil.delete(file);
assertEvent(VFileDeleteEvent.class, file.getAbsolutePath(), substFile.getAbsolutePath());
}
finally {
unwatch(request2);
}
myAccept = true;
FileUtil.writeToFile(file, "re-creation");
assertEvent(VFileCreateEvent.class, substFile.getAbsolutePath());
}
finally {
unwatch(request);
}
}
finally {
delete(targetDir);
IoTestUtil.deleteSubst(rootFile.getPath());
if (vfsRoot != null) {
((NewVirtualFile)vfsRoot).markDirty();
myFileSystem.refresh(false);
}
VirtualDirectoryImpl.disallowRootAccess(rootFile.getPath());
}
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:55,代码来源:FileWatcherTest.java
示例14: processQueue
import com.intellij.openapi.vfs.newvfs.impl.VirtualDirectoryImpl; //导入依赖的package包/类
private void processQueue(NewVirtualFileSystem fs, PersistentFS persistence) throws RefreshCancelledException {
TObjectHashingStrategy<String> strategy = FilePathHashingStrategy.create(fs.isCaseSensitive());
while (!myRefreshQueue.isEmpty()) {
Pair<NewVirtualFile, FileAttributes> pair = myRefreshQueue.pullFirst();
NewVirtualFile file = pair.first;
boolean fileDirty = file.isDirty();
if (LOG.isTraceEnabled()) LOG.trace("file=" + file + " dirty=" + fileDirty);
if (!fileDirty) continue;
checkCancelled(file);
FileAttributes attributes = pair.second != null ? pair.second : fs.getAttributes(file);
if (attributes == null) {
scheduleDeletion(file);
continue;
}
NewVirtualFile parent = file.getParent();
if (parent != null && checkAndScheduleFileTypeChange(parent, file, attributes)) {
// ignore everything else
file.markClean();
continue ;
}
if (file.isDirectory()) {
boolean fullSync = ((VirtualDirectoryImpl)file).allChildrenLoaded();
if (fullSync) {
fullDirRefresh(fs, persistence, strategy, (VirtualDirectoryImpl)file);
}
else {
partialDirRefresh(fs, strategy, (VirtualDirectoryImpl)file);
}
}
else {
long currentTimestamp = persistence.getTimeStamp(file);
long upToDateTimestamp = attributes.lastModified;
long currentLength = persistence.getLastRecordedLength(file);
long upToDateLength = attributes.length;
if (currentTimestamp != upToDateTimestamp || currentLength != upToDateLength) {
scheduleUpdateContent(file);
}
}
boolean currentWritable = persistence.isWritable(file);
boolean upToDateWritable = attributes.isWritable();
if (LOG_ATTRIBUTES.isDebugEnabled()) {
LOG_ATTRIBUTES.debug("file=" + file + " writable vfs=" + file.isWritable() + " persistence=" + currentWritable + " real=" + upToDateWritable);
}
if (currentWritable != upToDateWritable) {
scheduleAttributeChange(file, VirtualFile.PROP_WRITABLE, currentWritable, upToDateWritable);
}
if (SystemInfo.isWindows) {
boolean currentHidden = file.is(VFileProperty.HIDDEN);
boolean upToDateHidden = attributes.isHidden();
if (currentHidden != upToDateHidden) {
scheduleAttributeChange(file, VirtualFile.PROP_HIDDEN, currentHidden, upToDateHidden);
}
}
if (attributes.isSymLink()) {
String currentTarget = file.getCanonicalPath();
String upToDateTarget = fs.resolveSymLink(file);
String upToDateVfsTarget = upToDateTarget != null ? FileUtil.toSystemIndependentName(upToDateTarget) : null;
if (!Comparing.equal(currentTarget, upToDateVfsTarget)) {
scheduleAttributeChange(file, VirtualFile.PROP_SYMLINK_TARGET, currentTarget, upToDateVfsTarget);
}
}
if (myIsRecursive || !file.isDirectory()) {
file.markClean();
}
}
}
开发者ID:consulo,项目名称:consulo,代码行数:77,代码来源:RefreshWorker.java
注:本文中的com.intellij.openapi.vfs.newvfs.impl.VirtualDirectoryImpl类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论