/** * Updates visibility of the action presentation in various actions list. * Visible only for {@link IgnoreFile} context. * * @param e action event */ @Override public void update(@NotNull AnActionEvent e) { final PsiFile file = e.getData(CommonDataKeys.PSI_FILE); if (!(file instanceof IgnoreFile)) { e.getPresentation().setVisible(false); return; } getTemplatePresentation().setIcon(file.getFileType().getIcon()); } }
@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; }
private static void registerFileType(@NotNull FileTypeManager fileTypeManager, FileType fileType) { fileTypeManager.registerFileType(fileType, Collections.singletonList(new ExtensionFileNameMatcher(fileType.getDefaultExtension()))); }
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(); }
@Nullable @Override protected RunnerAndConfigurationSettings createConfigurationByElement(Location location, ConfigurationContext configurationContext) { sourceFile = location.getPsiElement().getContainingFile(); if (sourceFile != null && sourceFile.getFileType().getName().toLowerCase().contains("javascript")) { Project project = sourceFile.getProject(); VirtualFile file = sourceFile.getVirtualFile(); RunnerAndConfigurationSettings settings = cloneTemplateConfiguration(project, configurationContext); MongoRunConfiguration runConfiguration = (MongoRunConfiguration) settings.getConfiguration(); runConfiguration.setName(file.getName()); runConfiguration.setScriptPath(file.getPath()); Module module = ModuleUtil.findModuleForPsiElement(location.getPsiElement()); if (module != null) { runConfiguration.setModule(module); } return settings; } return null; }
private void register(@NotNull FileType fileType, @NotNull List<FileNameMatcher> fileNameMatchers) { FileTypeEntry type = fileTypes.get(fileType.getName()); if (type != null) { type.matchers.addAll(fileNameMatchers); } else { fileTypes.put(fileType.getName(), new FileTypeEntry(fileType, fileNameMatchers)); } } });
/** * Updates visibility of the action presentation in various actions list. * Visible only for {@link IgnoreFile} context. * * @param e action event */ @Override public void update(@NotNull AnActionEvent e) { final PsiFile file = e.getData(CommonDataKeys.PSI_FILE); if (!(file instanceof IgnoreFile)) { e.getPresentation().setVisible(false); return; } getTemplatePresentation().setIcon(file.getFileType().getIcon()); } }
@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; }
@Nonnull @CheckReturnValue public static String append(@Nonnull String fileName, @Nonnull FileType fileType) { final String extension = fileType.getDefaultExtension(); if (fileName.endsWith(DELIMITER + extension)) { return fileName; } return fileName + DELIMITER + extension; } }
@Override public void apply(@NotNull PsiFile file, AnnotationContext annotationResult, @NotNull AnnotationHolder holder) { // In PHPStorm the same PHP file is analyzed twice (once as PHP file and once as HTML file) if ("html".equalsIgnoreCase(file.getFileType().getName())) { return; } Collection<LiveIssue> issues = annotationResult.store.getForFile(file.getVirtualFile()); issues.stream() .filter(issue -> !issue.isResolved()) .forEach(issue -> { // reject non-null ranges that are no longer valid. It probably means that they were deleted from the file. RangeMarker range = issue.getRange(); if (range == null || range.isValid()) { addAnnotation(issue, holder); } }); }
@Override public boolean visitFile(@NotNull VirtualFile file) { String relativePath = VfsUtil.getRelativePath(file, containingDirectoryFiles, '/'); if (relativePath == null) { return super.visitFile(file); } completionResultSet.addElement(LookupElementBuilder.create(relativePath).withIcon(file.getFileType().getIcon())); return super.visitFile(file); } });
@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()); } }
@Nonnull @CheckReturnValue public static String remove(@Nonnull String fileName, @Nonnull FileType fileType) { final String extension = fileType.getDefaultExtension(); if (fileName.endsWith(DELIMITER + extension)) { return fileName.substring(0, fileName.length() - (extension.length() + 1)); } return fileName; }
@Override public void apply( @NotNull final PsiFile file, final AnnotationResult annotationResult, @NotNull final AnnotationHolder holder ) { if ( null == file.getVirtualFile() || null == ProjectFileIndex.SERVICE.getInstance(file.getProject()).getContentRootForFile(file.getVirtualFile()) || ( // Fixes #106: Annotations in PHPStorm shown twice per File "html".equalsIgnoreCase(file.getFileType().getName()) && "php".equalsIgnoreCase(file.getVirtualFile().getExtension())) ) { return; } createAnnotations(file,annotationResult,holder); }
public void renderElement(LookupElementPresentation presentation) { presentation.setItemText(getLookupString()); presentation.setIcon(this.virtualFile.getFileType().getIcon()); presentation.setTypeText(VfsUtil.getRelativePath(this.virtualFile, this.projectBaseDir, '/')); presentation.setTypeGrayed(true); } }
public static P4FileType getFileType(FilePath fp) { FileType ft = fp.getFileType(); if (ft.isBinary()) { return P4FileType.convert("binary"); } return P4FileType.convert("text"); } }
@Override public void consume(@NotNull FileType fileType) { register(fileType, parse(fileType.getDefaultExtension())); }
processor.process(new NavigationItemEx(psiFile, name, psiFile.getFileType().getIcon(), "Template"));
private P4FileType getFileType(FilePath fp) { FileType ft = fp.getFileType(); if (ft.isBinary()) { return P4FileType.convert("binary"); } return P4FileType.convert("text"); }