@NotNull @Override public Map<String, Set<String>> map(@NotNull FileContent inputData) { final Map<String, Set<String>> indexMap = new HashMap<>(); if (inputData.getFileType().isBinary()) { return indexMap; } final PsiFile file = inputData.getPsiFile(); if (fileDetector.isMainOpenApiFile(file)) { Set<String> partialOpenApiFileNames = getPartialOpenApiFileNames(file); indexMap.put(OpenApiFileIndex.PARTIAL_OPEN_API_FILES, partialOpenApiFileNames); indexMap.put( OpenApiFileIndex.MAIN_OPEN_API_FILE, ImmutableSet.of(file.getName() + DELIMITER + OpenApiFileType.MAIN)); } return indexMap; }
@NotNull @Override public Map<String, Set<String>> map(@NotNull FileContent inputData) { final Map<String, Set<String>> indexMap = new HashMap<>(); if (inputData.getFileType().isBinary()) { return indexMap; } final PsiFile file = inputData.getPsiFile(); if (fileDetector.isMainSwaggerFile(file)) { Set<String> partialSwaggerFileNames = getPartialSwaggerFileNames(file); indexMap.put(SwaggerFileIndex.PARTIAL_SWAGGER_FILES, partialSwaggerFileNames); indexMap.put( SwaggerFileIndex.MAIN_SWAGGER_FILE, ImmutableSet.of(file.getName() + DELIMITER + SwaggerFileType.MAIN)); } return indexMap; }
@Override public boolean visitFile(@NotNull VirtualFile file) { boolean projectFile = ProjectCoreUtil.isProjectOrWorkspaceFile(file, file.getFileType()); if (!file.isDirectory() && !file.getFileType().isBinary() && !projectFile) { files.add(file); } return !projectFile && !".git".equals(file.getName()); } }
private P4FileType getFileType(FilePath fp) { FileType ft = fp.getFileType(); if (ft.isBinary()) { return P4FileType.convert("binary"); } return P4FileType.convert("text"); }
public static P4FileType getFileType(FilePath fp) { FileType ft = fp.getFileType(); if (ft.isBinary()) { return P4FileType.convert("binary"); } return P4FileType.convert("text"); } }
private static List<VirtualFile> getFiles(@NotNull AnActionEvent e) { return JBIterable.of(e.getData(LangDataKeys.VIRTUAL_FILE_ARRAY)).filter(file -> { FileType fileType = file.getFileType(); return fileType == JFlexFileType.INSTANCE || !fileType.isBinary() && file.getName().endsWith(".flex"); }).toList(); }
@Test public void should_not_analyze_if_file_is_binary() { when(type.isBinary()).thenReturn(true); assertThat(exclusions.canAnalyze(testFile, module).isExcluded()).isTrue(); }
@Before public void prepare() { when(binary.isBinary()).thenReturn(true); when(testFile.getParent()).thenReturn(mock(VirtualFile.class)); when(testFile.isInLocalFileSystem()).thenReturn(true); when(testFile.isValid()).thenReturn(true); when(testFile.isInLocalFileSystem()).thenReturn(true); when(testFile.getFileType()).thenReturn(notBinary); }
@Before public void prepare() { when(powerModeCheck.getAsBoolean()).thenReturn(false); when(type.isBinary()).thenReturn(false); when(testFile.getParent()).thenReturn(mock(VirtualFile.class)); when(testFile.getFileType()).thenReturn(type); when(testFile.isInLocalFileSystem()).thenReturn(true); when(testFile.isValid()).thenReturn(true); when(info.getVersionName()).thenReturn("Intellij IDEA"); super.register(module, ModuleRootManager.class, moduleRootManager); }
public Result canAnalyze(VirtualFile file, @Nullable Module module) { FileType fileType = file.getFileType(); if (module == null) { return Result.excluded("file is not part of any module in IntelliJ's project structure"); } if (module.isDisposed() || module.getProject().isDisposed()) { return Result.excluded("module is disposed"); } if (!file.isInLocalFileSystem() || fileType.isBinary() || !file.isValid() || ".idea".equals(file.getParent().getName())) { return Result.excluded("file's type or location are not supported"); } // In PHPStorm the same PHP file is analyzed twice (once as PHP file and once as HTML file) String ijFlavor = applicationInfo.getVersionName().toLowerCase(Locale.US); if (ijFlavor.contains("phpstorm") && "html".equalsIgnoreCase(fileType.getName())) { return Result.excluded(null); } return Result.notExcluded(); }
private static void writeTemplateFiles(Module module, VirtualFile sdkBinDir, VirtualFile rootDir, NewProjectFileMap newProjectFileMap) { final GenericAttributeValue<String> baseDir = newProjectFileMap.getBaseDir(); // e.g templates/watch-app/simple String appName = module.getName(); // used in resources.xml to set freeform app name final Project project = module.getProject(); VelocityContext templateSubstitutionContext = getTemplateSubstitutionContext(appName); String sanitizedName = WordUtils.capitalize(appName); try { for (io.github.liias.monkey.project.dom.sdk.projectinfo.File file : newProjectFileMap.getFiles()) { final String relativeFilePath = file.getValue(); // e.g resources/images/launcher_icon.png String toRelativeFilePath = relativeFilePath; // source files are prefixed with app name if (FILE_TYPE_SOURCE.equals(file.getType().getStringValue())) { final Path relativeFilePathPath = Paths.get(relativeFilePath); final Path fileName = relativeFilePathPath.getFileName(); // e.g App.mc final Path parent = relativeFilePathPath.getParent(); // e.g source toRelativeFilePath = parent + "/" + sanitizedName + fileName; } final VirtualFile templateFile = sdkBinDir.findFileByRelativePath(baseDir + "/" + relativeFilePath); // this handles creating child directories as well VirtualFile newFile = VfsUtil.copyFileRelative(project, templateFile, rootDir, toRelativeFilePath); if (!newFile.getFileType().isBinary()) { String content = getParsedFileContent(templateSubstitutionContext, newFile); VfsUtil.saveText(newFile, content); } } } catch (IOException e) { LOG.error(e); } }