private static boolean isProductionGoFile(@NotNull PsiFile psiFile) { return psiFile.getFileType() == GoFileType.INSTANCE && !GoTestFinder.isTestFile(psiFile); }
/** Return whether or not this formatter can handle formatting the given file. */ private boolean overrideFormatterForFile(PsiFile file) { return StdFileTypes.JAVA.equals(file.getFileType()) && GoogleJavaFormatSettings.getInstance(getProject()).isEnabled(); }
/** * 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()); } }
/** * 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()); } }
@Override public void visitFile(PsiFile psiFile) { if(psiFile.getFileType() == PhpFileType.INSTANCE) { phpVisitor(holder, psiFile); } else if(psiFile.getFileType() == YAMLFileType.YML) { yamlVisitor(holder, psiFile); } else if(psiFile.getFileType() == XmlFileType.INSTANCE) { xmlVisitor(holder, psiFile); } } };
@Override protected boolean isValidForFile(@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) { if(file.getFileType() != XmlFileType.INSTANCE || !Symfony2ProjectComponent.isEnabled(project)) { return false; } return getMatchXmlTag(editor, file) != null; }
@Override public boolean isAvailable(@NotNull Project project, Editor editor, @NotNull PsiElement psiElement) { if(psiElement.getContainingFile().getFileType() != YAMLFileType.YML || !Symfony2ProjectComponent.isEnabled(psiElement.getProject())) { return false; } return YamlHelper.findServiceInContext(psiElement) != null; }
@Override public boolean accepts(@NotNull PsiFile psiFile, ProcessingContext processingContext) { if (psiFile.getFileType() != YAMLFileType.YML) { return false; } if (psiFile.getName().matches("(security|config).*\\.(yml|yaml)")) { return true; } VirtualFile virtualFile = psiFile.getVirtualFile(); if(virtualFile == null) { return false; } String relativePath = VfsExUtil.getRelativeProjectPath(psiFile.getProject(), virtualFile); return relativePath != null && relativePath.contains("config/packages/"); } };
@Override public boolean isAvailable(@NotNull Project project, Editor editor, @NotNull PsiElement psiElement) { if(psiElement.getContainingFile().getFileType() != XmlFileType.INSTANCE || !Symfony2ProjectComponent.isEnabled(psiElement.getProject())) { return false; } return XmlServiceArgumentIntention.getServiceTagValid(psiElement) != null; }
@Override public boolean isAvailable(@NotNull Project project, Editor editor, @NotNull PsiElement psiElement) { if(psiElement.getContainingFile().getFileType() != XmlFileType.INSTANCE || !Symfony2ProjectComponent.isEnabled(psiElement.getProject())) { return false; } XmlTag serviceTagValid = getServiceTagValid(psiElement); if(serviceTagValid == null) { return false; } if(!ServiceActionUtil.isValidXmlParameterInspectionService(serviceTagValid)) { return false; } return ServiceActionUtil.getXmlMissingArgumentTypes(serviceTagValid, true, new ContainerCollectionResolver.LazyServiceCollector(project)).size() > 0; }
private static boolean isValidFileType(final PsiFile psiFile, final PluginConfigurationManager pluginConfig) { return pluginConfig.getCurrent().getScanScope().includeNonJavaSources() || FileTypes.isJava(psiFile.getFileType()); }
@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; }
processor.process(new NavigationItemEx(psiFile, name, psiFile.getFileType().getIcon(), "Template"));
/** * @see fr.adrienbrault.idea.symfony2plugin.templating.util.TwigUtil#getElementOnTwigViewProvider */ public void testGetTransDefaultDomainOnInjectedElement() { myFixture.configureByText("foo.html.twig", "" + "{% trans_default_domain \"foo\" %}\n" + "<a href=\"#\">FOO<caret>BAR</a>" ); PsiElement psiElement = myFixture.getFile().findElementAt(myFixture.getCaretOffset()); assertTrue( TwigUtil.getElementOnTwigViewProvider(psiElement).getContainingFile().getFileType() == TwigFileType.INSTANCE ); }
@Override protected boolean isValidForFile(@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) { return file.getFileType() == MonkeyFileType.INSTANCE; }
/** * @see fr.adrienbrault.idea.symfony2plugin.templating.util.TwigUtil#getElementOnTwigViewProvider */ public void testGetTransDefaultDomainOnInjectedElementWithInvalidOversizesCaretOffset() { myFixture.configureByText("foo.html.twig", "<a href=\"#\">FOO<caret>BAR</a>"); PsiElement psiElement = myFixture.getFile().findElementAt(myFixture.getCaretOffset()); assertTrue( TwigUtil.getElementOnTwigViewProvider(psiElement).getContainingFile().getFileType() == TwigFileType.INSTANCE ); myFixture.configureByText("test.php", "<?php<caret> "); psiElement = myFixture.getFile().findElementAt(myFixture.getCaretOffset()); assertNull(TwigUtil.getElementOnTwigViewProvider(psiElement)); }
@Contract("null -> false") protected boolean isMyFile(@Nullable PsiFile file) { if (file == null || !file.isPhysical()) { return false; } FileType fileType = file.getFileType(); return fileType instanceof PurePerlFileType; } }
@Before public void set() { super.register(app, SonarLintGlobalSettings.class, globalSettings); super.register(SonarLintProjectSettings.class, projectSettings); when(psiFile.getTextRange()).thenReturn(psiFileRange); when(psiFile.getVirtualFile()).thenReturn(virtualFile); when(psiFile.getFileType()).thenReturn(JavaFileType.INSTANCE); }
@Override public void update(AnActionEvent e) { PsiFile psiFile = e.getDataContext().getData(PlatformDataKeys.PSI_FILE); if (psiFile != null && psiFile.getFileType() instanceof CypherFileType) { e.getPresentation().setEnabled(true); } else { e.getPresentation().setEnabled(false); } }
public BraceHighlighter(Editor editor) { this.editor = editor; this.project = this.editor.getProject(); this.document = this.editor.getDocument(); this.psiFile = PsiDocumentManager.getInstance(project).getPsiFile(document); this.fileType = psiFile.getFileType(); this.fileText = this.editor.getDocument().getImmutableCharSequence(); this.markupModelEx = (MarkupModelEx) this.editor.getMarkupModel(); }