@Override public Icon getIcon() { return GoFileType.INSTANCE.getIcon(); }
@Override public void createFileTypes(@NotNull FileTypeConsumer consumer) { consumer.consume(AsmIntelFileType.INSTANCE, new WildcardFileNameMatcher("*_amd64.s"), new WildcardFileNameMatcher("*_amd64p32.s"), new WildcardFileNameMatcher("*_386.s")); } }
@Override public void createFileTypes(@NotNull FileTypeConsumer consumer) { consumer.consume(GoFileType.INSTANCE, GoFileType.INSTANCE.getDefaultExtension()); } }
@Override public void createFileTypes(@NotNull FileTypeConsumer fileTypeConsumer) { fileTypeConsumer.consume(BallerinaFileType.INSTANCE); } }
/** * Shorthand for consuming ignore file types. * * @param consumer file types consumer * @param fileType file type to consume */ private void consume(@NotNull FileTypeConsumer consumer, @NotNull IgnoreFileType fileType) { consumer.consume(fileType, new ExactFileNameMatcher(fileType.getIgnoreLanguage().getFilename())); consumer.consume(fileType, fileType.getIgnoreLanguage().getExtension()); } }
/** * Associates given file with proper {@link IgnoreFileType}. * * @param fileName to associate * @param fileType file type to bind with pattern */ public static void associateFileType(@NotNull final String fileName, @NotNull final IgnoreFileType fileType) { final Application application = ApplicationManager.getApplication(); if (application.isDispatchThread()) { final FileTypeManager fileTypeManager = FileTypeManager.getInstance(); application.invokeLater(() -> application.runWriteAction(() -> { fileTypeManager.associate(fileType, new ExactFileNameMatcher(fileName)); FILE_TYPES_ASSOCIATION_QUEUE.remove(fileName); }), ModalityState.NON_MODAL); } else if (!FILE_TYPES_ASSOCIATION_QUEUE.containsKey(fileName)) { FILE_TYPES_ASSOCIATION_QUEUE.put(fileName, fileType); } }
private static Set<FileType> templateDataFileTypeSet(@NotNull VirtualFile virtualFile) { String path = virtualFile.getPath(); int pathLength = path.length(); FileTypeManager fileTypeManager = FileTypeManager.getInstance(); return fileTypeManager .getAssociations(Type.INSTANCE) .stream() .filter(ExtensionFileNameMatcher.class::isInstance) .map(ExtensionFileNameMatcher.class::cast) .map(ExtensionFileNameMatcher::getExtension) .map(extension -> '.' + extension) .filter(path::endsWith) .map(dotExtension -> path.substring(0, pathLength - dotExtension.length())) .map(fileTypeManager::getFileTypeByFileName) .collect(Collectors.toSet()); }
@NotNull public static String pad(@NotNull final Editor editor, @NotNull DataContext context, int line, final int to) { final int len = getLineLength(editor, line); if(len >= to) return ""; final VirtualFile virtualFile = EditorData.getVirtualFile(editor); final Project project = PlatformDataKeys.PROJECT.getData(context); final int limit = to - len; if (virtualFile != null) { final FileType fileType = FileTypeManager.getInstance().getFileTypeByFile(virtualFile); final CodeStyleSettings settings = project == null ? CodeStyle.getDefaultSettings() : CodeStyle.getSettings(project); if (settings.useTabCharacter(fileType)) { final int tabSize = settings.getTabSize(fileType); final int tabsCnt = limit / tabSize; final int spacesCnt = limit % tabSize; return StringUtil.repeat("\t", tabsCnt) + StringUtil.repeat(" ", spacesCnt); } } return StringUtil.repeat(" ", limit); }
@Override public void run() { if (project.isDisposed() || !ReadAction.compute(root::isValid)) return; final FileTypeManager fileTypeManager = FileTypeManager.getInstance(); final PushedFilePropertiesUpdater propertiesUpdater = PushedFilePropertiesUpdater.getInstance(project); VfsUtilCore.visitChildrenRecursively(root, new VirtualFileVisitor() { @Override public boolean visitFile(@NotNull VirtualFile file) { return ReadAction.compute(() -> { boolean proceedToChildren; if (fileTypeManager.isFileIgnored(file)) { proceedToChildren = false; } else { proceedToChildren = true; if (file.isDirectory()) { propertiesUpdater.findAndUpdateValue(file, LevelPropertyPusher.this, level); } } return proceedToChildren; }); } }); }
private static void registerFileType(@NotNull FileTypeManager fileTypeManager, FileType fileType) { fileTypeManager.registerFileType(fileType, Collections.singletonList(new ExtensionFileNameMatcher(fileType.getDefaultExtension()))); }
/** * 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()); } }
protected Type(com.intellij.lang.Language lang) { super(lang); FileTypeEditorHighlighterProviders.INSTANCE.addExplicitExtension( this, (project, fileType, virtualFile, editorColorsScheme) -> new TemplateHighlighter(project, virtualFile, editorColorsScheme) ); }
@Override @NotNull public String getDisplayName() { return GoFileType.INSTANCE.getName(); }
private void registerProjectFileIndex(MessageBus messageBus) throws ClassNotFoundException, NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException { DirectoryIndex directoryIndex = registerDirectoryIndex(messageBus); FileTypeRegistry fileTypeRegistry = new MockFileTypeManager(); myProject.registerService( ProjectFileIndex.class, new ProjectFileIndexImpl(myProject, directoryIndex, fileTypeRegistry) ); }
@Override public boolean visitFile(@NotNull VirtualFile file) { return ReadAction.compute(() -> { boolean proceedToChildren; if (fileTypeManager.isFileIgnored(file)) { proceedToChildren = false; } else { proceedToChildren = true; if (file.isDirectory()) { propertiesUpdater.findAndUpdateValue(file, LevelPropertyPusher.this, level); } } return proceedToChildren; }); } });
public Test() { super("eex", new ParserDefinition(), new ElixirParserDefinition(), new HTMLParserDefinition(), new PlainTextParserDefinition()); }
@Override public void createFileTypes(@NotNull FileTypeConsumer consumer) { consumer.consume(FileType.INSTANCE, "beam"); } }
@Override public void createFileTypes(@NotNull FileTypeConsumer fileTypeConsumer) { LanguageFileType type = Type.INSTANCE; fileTypeConsumer.consume(type, type.getDefaultExtension()); } }
/** * 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()); } }