@Override public void valueChange(OptionChangeEvent event) { for (VimExtension extension : Extensions.getExtensions(VimExtension.EP_NAME)) { if (name.equals(extension.getName())) { if (Options.getInstance().isSet(name)) { extension.init(); logger.info("IdeaVim extension '" + name + "' initialized"); } else { extension.dispose(); } } } } });
private void registerExtensionOptions() { for (VimExtension extension : Extensions.getExtensions(VimExtension.EP_NAME)) { final String name = extension.getName(); final ToggleOption option = new ToggleOption(name, name, false); option.addOptionChangeListener(new OptionChangeListener() { @Override public void valueChange(OptionChangeEvent event) { for (VimExtension extension : Extensions.getExtensions(VimExtension.EP_NAME)) { if (name.equals(extension.getName())) { if (Options.getInstance().isSet(name)) { extension.init(); logger.info("IdeaVim extension '" + name + "' initialized"); } else { extension.dispose(); } } } } }); addOption(option); } }
debouncedStatusesChanged.run(); for (AbstractProjectViewPane pane : Extensions.getExtensions(AbstractProjectViewPane.EP_NAME, myProject)) { if (pane.getTreeBuilder() != null) { pane.getTreeBuilder().queueUpdate();
public void assertNavigationContains(PsiElement psiElement, String targetShortcut) { if(!targetShortcut.startsWith("\\")) { targetShortcut = "\\" + targetShortcut; } Set<String> classTargets = new HashSet<String>(); for (GotoDeclarationHandler gotoDeclarationHandler : Extensions.getExtensions(GotoDeclarationHandler.EP_NAME)) { PsiElement[] gotoDeclarationTargets = gotoDeclarationHandler.getGotoDeclarationTargets(psiElement, 0, myFixture.getEditor()); if(gotoDeclarationTargets != null && gotoDeclarationTargets.length > 0) { for (PsiElement gotoDeclarationTarget : gotoDeclarationTargets) { if(gotoDeclarationTarget instanceof Method) { String meName = ((Method) gotoDeclarationTarget).getName(); String clName = ((Method) gotoDeclarationTarget).getContainingClass().getPresentableFQN(); if(!clName.startsWith("\\")) { clName = "\\" + clName; } classTargets.add(clName + "::" + meName); } else if(gotoDeclarationTarget instanceof Function) { classTargets.add("\\" + ((Function) gotoDeclarationTarget).getName()); } } } } if(!classTargets.contains(targetShortcut)) { fail(String.format("failed that PsiElement (%s) navigate to %s on %s", psiElement.toString(), targetShortcut, classTargets.toString())); } }
private void assertNavigationIsEmpty() { PsiElement psiElement = myFixture.getFile().findElementAt(myFixture.getCaretOffset()); for (GotoDeclarationHandler gotoDeclarationHandler : Extensions.getExtensions(GotoDeclarationHandler.EP_NAME)) { PsiElement[] gotoDeclarationTargets = gotoDeclarationHandler.getGotoDeclarationTargets(psiElement, 0, myFixture.getEditor()); if(gotoDeclarationTargets != null && gotoDeclarationTargets.length > 0) { fail(String.format("failed that PsiElement (%s) navigate is empty; found target in '%s'", psiElement.toString(), gotoDeclarationHandler.getClass())); } } }
private void assertNavigationMatch(ElementPattern<?> pattern) { PsiElement psiElement = myFixture.getFile().findElementAt(myFixture.getCaretOffset()); Set<String> targetStrings = new HashSet<String>(); for (GotoDeclarationHandler gotoDeclarationHandler : Extensions.getExtensions(GotoDeclarationHandler.EP_NAME)) { PsiElement[] gotoDeclarationTargets = gotoDeclarationHandler.getGotoDeclarationTargets(psiElement, 0, myFixture.getEditor()); if(gotoDeclarationTargets == null || gotoDeclarationTargets.length == 0) { continue; } for (PsiElement gotoDeclarationTarget : gotoDeclarationTargets) { targetStrings.add(gotoDeclarationTarget.toString()); if(pattern.accepts(gotoDeclarationTarget)) { return; } } } fail(String.format("failed that PsiElement (%s) navigate matches one of %s", psiElement.toString(), targetStrings.toString())); }
private HybrisProjectImportProvider getHybrisProjectImportProvider() { for (ProjectImportProvider provider : Extensions.getExtensions(ProjectImportProvider.PROJECT_IMPORT_PROVIDER)) { if (provider instanceof HybrisProjectImportProvider) { return (HybrisProjectImportProvider) provider; } } return null; }
public AndroidUiFacade() { this.messageExtenders = Extensions.getExtensions(GoogleLoginMessageExtender.EP_NAME); }
public void assertNavigationContainsFile(LanguageFileType languageFileType, String configureByText, String targetShortcut) { myFixture.configureByText(languageFileType, configureByText); PsiElement psiElement = myFixture.getFile().findElementAt(myFixture.getCaretOffset()); Set<String> targets = new HashSet<String>(); for (GotoDeclarationHandler gotoDeclarationHandler : Extensions.getExtensions(GotoDeclarationHandler.EP_NAME)) { PsiElement[] gotoDeclarationTargets = gotoDeclarationHandler.getGotoDeclarationTargets(psiElement, 0, myFixture.getEditor()); if (gotoDeclarationTargets != null && gotoDeclarationTargets.length > 0) { for (PsiElement gotoDeclarationTarget : gotoDeclarationTargets) { if(gotoDeclarationTarget instanceof PsiFile) { targets.add(((PsiFile) gotoDeclarationTarget).getVirtualFile().getUrl()); } } } } // its possible to have memory fields, // so simple check for ending conditions // temp:///src/interchange.en.xlf for (String target : targets) { if(target.endsWith(targetShortcut)) { return; } } fail(String.format("failed that PsiElement (%s) navigate to file %s", psiElement.toString(), targetShortcut)); }
@NotNull public static HybrisWritingAccessProvider getInstance(@NotNull final Project project) { return Arrays.stream(Extensions.getExtensions(EP_NAME, project)) .map(o -> ObjectUtils.tryCast(o, HybrisWritingAccessProvider.class)) .filter(Objects::nonNull) .findAny() .orElseThrow(IllegalStateException::new); }
@NotNull @Override public List<DeploymentSource> getAvailableDeploymentSources() { AppEngineDeploymentSourceProvider[] deploymentSourceProviders = Extensions.getExtensions(AppEngineDeploymentSourceProvider.EP_NAME); return Stream.of(deploymentSourceProviders) .flatMap( deploymentSourceProvider -> deploymentSourceProvider.getDeploymentSources(project).stream()) .collect(Collectors.toList()); }
static boolean hasJunitExtensionPoint() { try { Extensions.getExtensions(JUNIT_EP_NAME); return true; } catch (IllegalArgumentException e) { // e.printStackTrace(); return false; } }
private List<RunnerAndConfigurationSettings> getAllRunConfigurations() { if (runtimeConfigurationProviders == null) { // build initial map of providers to list of their configurations. runtimeConfigurationProviders = Stream.of(Extensions.getExtensions(CloudApiRunConfigurationProvider.EP_NAME)) .collect( Collectors.toMap( Function.identity(), configProvider -> configProvider.getRunConfigurationsForCloudApis(project))); } // return flat list of all runtime configurations for UI table model. return runtimeConfigurationProviders .values() .stream() .flatMap(Collection::stream) .collect(Collectors.toList()); }
@NotNull public static <Psi extends PsiElement> List<Psi> collectAugments(@NotNull final PsiElement element, @NotNull final Class<Psi> type) { List<Psi> result = Collections.emptyList(); for (PsiAugmentProvider provider : DumbService.getInstance(element.getProject()).filterByDumbAwareness(Extensions.getExtensions(EP_NAME))) { List<Psi> augments = provider.getAugments(element, type); if (!augments.isEmpty()) { if (result.isEmpty()) result = new ArrayList<Psi>(augments.size()); result.addAll(augments); } } return result; }
@Nullable private static TestFramework computeFramework(PsiClass psiClass) { for (TestFramework framework : Extensions.getExtensions(TestFramework.EXTENSION_NAME)) { if (framework.isTestClass(psiClass)) { return framework; } } for (TestFramework framework : Extensions.getExtensions(TestFramework.EXTENSION_NAME)) { if (framework.findSetUpMethod(psiClass) != null || framework.findTearDownMethod(psiClass) != null) { return framework; } } return null; } }
public static InspectionProfileEntry findInspectionProfileEntry(Class<? extends LocalInspectionTool> clazz) { LocalInspectionEP[] extensions = Extensions.getExtensions(LocalInspectionEP.LOCAL_INSPECTION); for (LocalInspectionEP extension : extensions) { if (extension.implementationClass.equals(clazz.getCanonicalName())) { extension.enabledByDefault = true; return extension.instantiateTool(); } } throw new IllegalStateException("Unable to find inspection profile entry for " + clazz); }
private void enableInspections() { Class[] inspectionClasses = new BashTestInspections().getInspectionClasses(); ArrayList<InspectionProfileEntry> inspections = new ArrayList<InspectionProfileEntry>(); LocalInspectionEP[] extensions = Extensions.getExtensions(LocalInspectionEP.LOCAL_INSPECTION); for (LocalInspectionEP extension : extensions) { for (Class inspectionClass : inspectionClasses) { if (extension.implementationClass.equals(inspectionClass.getCanonicalName())) { extension.enabledByDefault = true; inspections.add(extension.instantiateTool()); } } } myFixture.enableInspections(inspections.toArray(new InspectionProfileEntry[inspections.size()])); }
private void doRename(PsiFile psiElement, String newName) { final RenameProcessor processor = new RenameProcessor(myProject, psiElement, newName, false, false); for (AutomaticRenamerFactory factory : Extensions.getExtensions(AutomaticRenamerFactory.EP_NAME)) { processor.addRenamerFactory(factory); } processor.run(); PsiDocumentManager.getInstance(myProject).commitAllDocuments(); FileDocumentManager.getInstance().saveAllDocuments(); } }
private void notifyCheckoutListeners(final File directory, final boolean checkoutCompleted) { final VirtualFile file = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(directory); final AddModuleWizard wizard = ImportModuleAction.createImportWizard(null, null, file, ProjectImportProvider.PROJECT_IMPORT_PROVIDER.getExtensions()); if (wizard == null) return; ImportModuleAction.createFromWizard(null, wizard); if (!checkoutCompleted) { final VcsAwareCheckoutListener[] vcsAwareExtensions = Extensions.getExtensions(VcsAwareCheckoutListener.EP_NAME); for (VcsAwareCheckoutListener extension : vcsAwareExtensions) { boolean processingCompleted = extension.processCheckedOutDirectory(myProject, directory, myVcsKey); if (processingCompleted) break; } } newProject = findProjectByBaseDirLocation(directory); }
public void testRenameImportedProtoAtCaretPosition() { PsiFile[] files = myFixture.configureByFiles( "rename/import/source.proto", "rename/import/import.proto" ); PsiElement elementAtCaret = myFixture.getElementAtCaret(); Project project = myFixture.getProject(); RenameProcessor processor = new RenameProcessor(project, elementAtCaret, "renamed.proto", false, false); for (AutomaticRenamerFactory factory : Extensions.getExtensions(AutomaticRenamerFactory.EP_NAME)) { processor.addRenamerFactory(factory); } processor.run(); Assert.assertEquals("renamed.proto", files[1].getName()); Assert.assertEquals("import \"rename/import/renamed.proto\";", ((ProtoPsiFileRoot) files[0]).getProtoRoot().getImports().get(0).getText()); }