use of com.intellij.openapi.fileTypes.FileTypeManager in project intellij-community by JetBrains.
the class PythonLanguageLevelPusher method markRecursively.
private void markRecursively(final Project project, @NotNull final VirtualFile file, final LanguageLevel languageLevel, final boolean suppressSizeLimit) {
final FileTypeManager fileTypeManager = FileTypeManager.getInstance();
VfsUtilCore.visitChildrenRecursively(file, new VirtualFileVisitor() {
@Override
public boolean visitFile(@NotNull VirtualFile file) {
if (fileTypeManager.isFileIgnored(file)) {
return false;
}
if (file.isDirectory()) {
PushedFilePropertiesUpdater.getInstance(project).findAndUpdateValue(file, PythonLanguageLevelPusher.this, languageLevel);
}
if (suppressSizeLimit) {
SingleRootFileViewProvider.doNotCheckFileSizeLimit(file);
}
return true;
}
});
}
use of com.intellij.openapi.fileTypes.FileTypeManager in project intellij-community by JetBrains.
the class ModuleChunkSourcePath method addExcludePatterns.
private static void addExcludePatterns(Module module, final VirtualFile root, VirtualFile dir, final CompositeGenerator generator, final boolean parentIncluded) {
final FileTypeManager fileTypeManager = FileTypeManager.getInstance();
final ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(module);
VfsUtilCore.visitChildrenRecursively(dir, new VirtualFileVisitor() {
@Override
public boolean visitFile(@NotNull VirtualFile dir) {
if (!dir.isDirectory() || fileTypeManager.isFileIgnored(dir)) {
// ignored files are handled by global 'ignored' pattern set
return false;
}
final boolean isIncluded = moduleRootManager.getFileIndex().isInContent(dir);
if (isIncluded != parentIncluded) {
final String relativePath = VfsUtilCore.getRelativePath(dir, root, '/');
if (isIncluded) {
generator.add(new Include(relativePath + "/**"));
} else {
if (!isExcludedByDefault(dir.getName())) {
generator.add(new Exclude(relativePath + "/**"));
}
}
}
return true;
}
});
}
use of com.intellij.openapi.fileTypes.FileTypeManager in project intellij-community by JetBrains.
the class LocalFilePath method getFileType.
@Override
@NotNull
public FileType getFileType() {
VirtualFile file = getVirtualFile();
FileTypeManager manager = FileTypeManager.getInstance();
return file != null ? manager.getFileTypeByFile(file) : manager.getFileTypeByFileName(getName());
}
use of com.intellij.openapi.fileTypes.FileTypeManager in project intellij-community by JetBrains.
the class JavaVfsSourceRootDetectionUtil method suggestRoots.
/**
* Scan directory and detect java source roots within it. The source root is detected as the following:
* <ol>
* <li>It contains at least one Java file.</li>
* <li>Java file is located in the sub-folder that matches package statement in the file.</li>
* </ol>
*
* @param dir a directory to scan
* @param progressIndicator
* @return a list of found source roots within directory. If no source roots are found, a empty list is returned.
*/
@NotNull
public static List<VirtualFile> suggestRoots(@NotNull VirtualFile dir, @NotNull final ProgressIndicator progressIndicator) {
if (!dir.isDirectory()) {
return ContainerUtil.emptyList();
}
final FileTypeManager typeManager = FileTypeManager.getInstance();
final ArrayList<VirtualFile> foundDirectories = new ArrayList<>();
try {
VfsUtilCore.visitChildrenRecursively(dir, new VirtualFileVisitor() {
@NotNull
@Override
public Result visitFileEx(@NotNull VirtualFile file) {
progressIndicator.checkCanceled();
if (file.isDirectory()) {
if (typeManager.isFileIgnored(file) || StringUtil.startsWithIgnoreCase(file.getName(), "testData")) {
return SKIP_CHILDREN;
}
} else {
FileType type = typeManager.getFileTypeByFileName(file.getName());
if (StdFileTypes.JAVA == type) {
VirtualFile root = suggestRootForJavaFile(file);
if (root != null) {
foundDirectories.add(root);
return skipTo(root);
}
}
}
return CONTINUE;
}
});
} catch (ProcessCanceledException ignore) {
}
return foundDirectories;
}
use of com.intellij.openapi.fileTypes.FileTypeManager in project intellij-community by JetBrains.
the class PsiVFSListener method createFileCopyWithNewName.
@Nullable
private PsiFile createFileCopyWithNewName(VirtualFile vFile, String name) {
// TODO[ik] remove this. Event handling and generation must be in view providers mechanism since we
// need to track changes in _all_ psi views (e.g. namespace changes in XML)
final FileTypeManager instance = FileTypeManager.getInstance();
if (instance.isFileIgnored(name))
return null;
final FileType fileTypeByFileName = instance.getFileTypeByFileName(name);
final Document document = FileDocumentManager.getInstance().getDocument(vFile);
return PsiFileFactory.getInstance(myManager.getProject()).createFileFromText(name, fileTypeByFileName, document != null ? document.getCharsSequence() : "", vFile.getModificationStamp(), true, false);
}
Aggregations