use of com.intellij.openapi.vfs.newvfs.impl.VirtualFileSystemEntry in project intellij-community by JetBrains.
the class LocalFileSystemTest method testBadFileName.
public void testBadFileName() throws Exception {
if (!SystemInfo.isUnix) {
System.err.println(getName() + " skipped: " + SystemInfo.OS_NAME);
return;
}
final File dir = FileUtil.createTempDirectory("test.", ".dir");
final File file = FileUtil.createTempFile(dir, "test\\", "\\txt", true);
final VirtualFile vDir = myFS.refreshAndFindFileByIoFile(dir);
assertNotNull(vDir);
assertEquals(0, vDir.getChildren().length);
((VirtualFileSystemEntry) vDir).markDirtyRecursively();
vDir.refresh(false, true);
final VirtualFile vFile = myFS.refreshAndFindFileByIoFile(file);
assertNull(vFile);
}
use of com.intellij.openapi.vfs.newvfs.impl.VirtualFileSystemEntry in project intellij-community by JetBrains.
the class IdeaGateway method doCreateEntry.
@Nullable
private Entry doCreateEntry(@NotNull VirtualFile file, boolean forDeletion) {
if (!file.isDirectory()) {
if (!isVersioned(file))
return null;
Pair<StoredContent, Long> contentAndStamps;
if (forDeletion) {
FileDocumentManager m = FileDocumentManager.getInstance();
// should not try to load document
Document d = m.isFileModified(file) ? m.getCachedDocument(file) : null;
contentAndStamps = acquireAndClearCurrentContent(file, d);
} else {
contentAndStamps = getActualContentNoAcquire(file);
}
return doCreateFileEntry(file, contentAndStamps);
}
DirectoryEntry newDir = null;
if (file instanceof VirtualFileSystemEntry) {
int nameId = ((VirtualFileSystemEntry) file).getNameId();
if (nameId > 0) {
newDir = new DirectoryEntry(nameId);
}
}
if (newDir == null) {
newDir = new DirectoryEntry(file.getName());
}
doCreateChildren(newDir, iterateDBChildren(file), forDeletion);
if (!isVersioned(file) && newDir.getChildren().isEmpty())
return null;
return newDir;
}
use of com.intellij.openapi.vfs.newvfs.impl.VirtualFileSystemEntry in project idea-php-typo3-plugin by cedricziel.
the class ExtensionDefinitionFactory method fromDirectory.
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;
}
use of com.intellij.openapi.vfs.newvfs.impl.VirtualFileSystemEntry in project intellij-community by JetBrains.
the class ComputeVirtualFileNameStatAction method compute.
private void compute(VirtualFile root) {
String name = root.getName();
if (!nameCount.increment(name))
nameCount.put(name, 1);
for (int i = 1; i <= name.length(); i++) {
//String prefix = name.substring(0, i);
//if (!prefixes.increment(prefix)) prefixes.put(prefix, 1);
String suffix = name.substring(name.length() - i);
if (!suffixes.increment(suffix))
suffixes.put(suffix, 1);
}
Collection<VirtualFile> cachedChildren = ((VirtualFileSystemEntry) root).getCachedChildren();
//VirtualFile[] cachedChildren = ((VirtualFileSystemEntry)root).getChildren();
for (VirtualFile cachedChild : cachedChildren) {
compute(cachedChild);
}
}
use of com.intellij.openapi.vfs.newvfs.impl.VirtualFileSystemEntry in project intellij-community by JetBrains.
the class InlineLibraryMethodTest method testInlineAllInProjectFromLibrary.
public void testInlineAllInProjectFromLibrary() throws Exception {
configureByText(JavaFileType.INSTANCE, "package mycompany;\n" + "public class File {\n" + " public static File createTempFile(String pr, String postfix){return createTempFile(pr, postfix, null);}\n" + " public static File createTempFile(String pr, String postfix, String base){return new File();}\n" + "}");
@NonNls String fileName = "/refactoring/inlineMethod/" + getTestName(false) + ".java";
configureByFile(fileName);
PsiClass fileClass = getJavaFacade().findClass("mycompany.File");
assertNotNull(fileClass);
final PsiFile file = fileClass.getContainingFile();
WriteCommandAction.runWriteCommandAction(null, () -> {
try {
((VirtualFileSystemEntry) file.getVirtualFile()).setWritable(false);
} catch (IOException e) {
throw new RuntimeException(e);
}
});
PsiElement element = null;
PsiMethod[] createTempFiles = fileClass.findMethodsByName("createTempFile", false);
for (PsiMethod createTempFile : createTempFiles) {
if (createTempFile.getParameterList().getParametersCount() == 2) {
element = createTempFile;
break;
}
}
assertNotNull(element);
PsiMethod method = (PsiMethod) element;
final boolean condition = InlineMethodProcessor.checkBadReturns(method) && !InlineUtil.allUsagesAreTailCalls(method);
assertFalse("Bad returns found", condition);
final InlineMethodProcessor processor = new InlineMethodProcessor(getProject(), method, null, myEditor, false);
processor.run();
checkResultByFile(fileName + ".after");
}
Aggregations