public String[] knownNamespaces() { final PsiElement parentElement = getParent(); BidirectionalMap<String, String> map = initNamespaceMaps(parentElement); Set<String> known = Collections.emptySet(); if (map != null) { known = new HashSet<String>(map.values()); } if (parentElement instanceof XmlTag) { if (known.isEmpty()) return ((XmlTag) parentElement).knownNamespaces(); ContainerUtil.addAll(known, ((XmlTag) parentElement).knownNamespaces()); } else { XmlExtension xmlExtension = XmlExtension.getExtensionByElement(this); if (xmlExtension != null) { final XmlFile xmlFile = xmlExtension.getContainingFile(this); if (xmlFile != null) { final XmlTag rootTag = xmlFile.getRootTag(); if (rootTag != null && rootTag != this) { if (known.isEmpty()) return rootTag.knownNamespaces(); ContainerUtil.addAll(known, rootTag.knownNamespaces()); } } } } return ArrayUtil.toStringArray(known); }
private NamesByExprInfo suggestVariableNameByExpression( PsiExpression expr, VariableKind variableKind, boolean correctKeywords) { final LinkedHashSet<String> names = new LinkedHashSet<String>(); final String[] fromLiterals = suggestVariableNameFromLiterals(expr, variableKind, correctKeywords); if (fromLiterals != null) { ContainerUtil.addAll(names, fromLiterals); } ContainerUtil.addAll( names, suggestVariableNameByExpressionOnly(expr, variableKind, correctKeywords, false).names); ContainerUtil.addAll( names, suggestVariableNameByExpressionPlace(expr, variableKind, correctKeywords).names); PsiType type = expr.getType(); if (type != null) { ContainerUtil.addAll(names, suggestVariableNameByType(type, variableKind, correctKeywords)); } ContainerUtil.addAll( names, suggestVariableNameByExpressionOnly(expr, variableKind, correctKeywords, true).names); String[] namesArray = ArrayUtil.toStringArray(names); String propertyName = suggestVariableNameByExpressionOnly(expr, variableKind, correctKeywords, false).propertyName != null ? suggestVariableNameByExpressionOnly(expr, variableKind, correctKeywords, false) .propertyName : suggestVariableNameByExpressionPlace(expr, variableKind, correctKeywords) .propertyName; return new NamesByExprInfo(propertyName, namesArray); }
private void createEditors(@Nullable Module module) { if (module == null) return; ModuleConfigurationState state = createModuleConfigurationState(); for (ModuleConfigurationEditorProvider provider : collectProviders(module)) { ModuleConfigurationEditor[] editors = provider.createEditors(state); if (editors.length > 0 && provider instanceof ModuleConfigurationEditorProviderEx && ((ModuleConfigurationEditorProviderEx) provider).isCompleteEditorSet()) { myEditors.clear(); ContainerUtil.addAll(myEditors, editors); break; } else { ContainerUtil.addAll(myEditors, editors); } } for (Configurable moduleConfigurable : ServiceKt.getComponents(module, Configurable.class)) { reportDeprecatedModuleEditor(moduleConfigurable.getClass()); myEditors.add(new ModuleConfigurableWrapper(moduleConfigurable)); } for (ModuleConfigurableEP extension : module.getExtensions(MODULE_CONFIGURABLES)) { if (extension.canCreateConfigurable()) { Configurable configurable = extension.createConfigurable(); if (configurable != null) { reportDeprecatedModuleEditor(configurable.getClass()); myEditors.add(new ModuleConfigurableWrapper(configurable)); } } } }
public NextOccurrenceAction( EditorSearchComponent editorSearchComponent, Getter<JTextComponent> editorTextField) { super(editorSearchComponent); myTextField = editorTextField; copyFrom(ActionManager.getInstance().getAction(IdeActions.ACTION_NEXT_OCCURENCE)); ArrayList<Shortcut> shortcuts = new ArrayList<Shortcut>(); ContainerUtil.addAll( shortcuts, ActionManager.getInstance() .getAction(IdeActions.ACTION_FIND_NEXT) .getShortcutSet() .getShortcuts()); if (!editorSearchComponent.getFindModel().isMultiline()) { ContainerUtil.addAll( shortcuts, ActionManager.getInstance() .getAction(IdeActions.ACTION_EDITOR_MOVE_CARET_DOWN) .getShortcutSet() .getShortcuts()); shortcuts.add(new KeyboardShortcut(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), null)); } registerShortcutsForComponent(shortcuts, editorTextField.get()); }
private static ModuleConfigurationEditorProvider[] collectProviders(final Module module) { List<ModuleConfigurationEditorProvider> result = new ArrayList<ModuleConfigurationEditorProvider>(); ContainerUtil.addAll(result, module.getComponents(ModuleConfigurationEditorProvider.class)); ContainerUtil.addAll( result, Extensions.getExtensions(ModuleConfigurationEditorProvider.EP_NAME, module)); return result.toArray(new ModuleConfigurationEditorProvider[result.size()]); }
@Override public SuggestedNameInfo suggestVariableName( @NotNull final VariableKind kind, @Nullable final String propertyName, @Nullable final PsiExpression expr, @Nullable PsiType type, final boolean correctKeywords) { LinkedHashSet<String> names = new LinkedHashSet<String>(); if (expr != null && type == null) { type = expr.getType(); } if (propertyName != null) { String[] namesByName = getSuggestionsByName(propertyName, kind, false, correctKeywords); sortVariableNameSuggestions(namesByName, kind, propertyName, null); ContainerUtil.addAll(names, namesByName); } final NamesByExprInfo namesByExpr; if (expr != null) { namesByExpr = suggestVariableNameByExpression(expr, kind, correctKeywords); if (namesByExpr.propertyName != null) { sortVariableNameSuggestions(namesByExpr.names, kind, namesByExpr.propertyName, null); } ContainerUtil.addAll(names, namesByExpr.names); } else { namesByExpr = null; } if (type != null) { String[] namesByType = suggestVariableNameByType(type, kind, correctKeywords); sortVariableNameSuggestions(namesByType, kind, null, type); ContainerUtil.addAll(names, namesByType); } final String _propertyName; if (propertyName != null) { _propertyName = propertyName; } else { _propertyName = namesByExpr != null ? namesByExpr.propertyName : null; } addNamesFromStatistics(names, kind, _propertyName, type); String[] namesArray = ArrayUtil.toStringArray(names); sortVariableNameSuggestions(namesArray, kind, _propertyName, type); final PsiType _type = type; return new SuggestedNameInfo(namesArray) { @Override public void nameChosen(String name) { if (_propertyName != null || _type != null && _type.isValid()) { JavaStatisticsManager.incVariableNameUseCount(name, kind, _propertyName, _type); } } }; }
@TestOnly private static VirtualFile[] getAllRoots(@NotNull Project project) { insideGettingRoots = true; final Set<VirtualFile> roots = new THashSet<VirtualFile>(); final OrderEnumerator enumerator = ProjectRootManager.getInstance(project).orderEntries(); ContainerUtil.addAll(roots, enumerator.getClassesRoots()); ContainerUtil.addAll(roots, enumerator.getSourceRoots()); insideGettingRoots = false; return VfsUtilCore.toVirtualFileArray(roots); }
private static void processCallerMethod( JavaChangeInfo changeInfo, PsiMethod caller, PsiMethod baseMethod, boolean toInsertParams, boolean toInsertThrows) throws IncorrectOperationException { LOG.assertTrue(toInsertParams || toInsertThrows); if (toInsertParams) { List<PsiParameter> newParameters = new ArrayList<PsiParameter>(); ContainerUtil.addAll(newParameters, caller.getParameterList().getParameters()); final JavaParameterInfo[] primaryNewParms = changeInfo.getNewParameters(); PsiSubstitutor substitutor = baseMethod == null ? PsiSubstitutor.EMPTY : ChangeSignatureProcessor.calculateSubstitutor(caller, baseMethod); for (JavaParameterInfo info : primaryNewParms) { if (info.getOldIndex() < 0) newParameters.add(createNewParameter(changeInfo, info, substitutor)); } PsiParameter[] arrayed = newParameters.toArray(new PsiParameter[newParameters.size()]); boolean[] toRemoveParm = new boolean[arrayed.length]; Arrays.fill(toRemoveParm, false); resolveParameterVsFieldsConflicts(arrayed, caller, caller.getParameterList(), toRemoveParm); } if (toInsertThrows) { List<PsiJavaCodeReferenceElement> newThrowns = new ArrayList<PsiJavaCodeReferenceElement>(); final PsiReferenceList throwsList = caller.getThrowsList(); ContainerUtil.addAll(newThrowns, throwsList.getReferenceElements()); final ThrownExceptionInfo[] primaryNewExns = changeInfo.getNewExceptions(); for (ThrownExceptionInfo thrownExceptionInfo : primaryNewExns) { if (thrownExceptionInfo.getOldIndex() < 0) { final PsiClassType type = (PsiClassType) thrownExceptionInfo.createType(caller, caller.getManager()); final PsiJavaCodeReferenceElement ref = JavaPsiFacade.getInstance(caller.getProject()) .getElementFactory() .createReferenceElementByType(type); newThrowns.add(ref); } } PsiJavaCodeReferenceElement[] arrayed = newThrowns.toArray(new PsiJavaCodeReferenceElement[newThrowns.size()]); boolean[] toRemoveParm = new boolean[arrayed.length]; Arrays.fill(toRemoveParm, false); ChangeSignatureUtil.synchronizeList( throwsList, Arrays.asList(arrayed), ThrowsList.INSTANCE, toRemoveParm); } }
private static PsiAnnotation[] getHierarchyAnnotations( PsiModifierListOwner listOwner, PsiModifierList modifierList) { final Set<PsiAnnotation> all = new HashSet<PsiAnnotation>() { public boolean add(PsiAnnotation o) { // don't overwrite "higher level" annotations return !contains(o) && super.add(o); } }; if (listOwner instanceof PsiMethod) { ContainerUtil.addAll(all, modifierList.getAnnotations()); SuperMethodsSearch.search((PsiMethod) listOwner, null, true, true) .forEach( new Processor<MethodSignatureBackedByPsiMethod>() { public boolean process(final MethodSignatureBackedByPsiMethod superMethod) { ContainerUtil.addAll( all, superMethod.getMethod().getModifierList().getAnnotations()); return true; } }); return all.toArray(new PsiAnnotation[all.size()]); } if (listOwner instanceof PsiParameter) { PsiParameter parameter = (PsiParameter) listOwner; PsiElement declarationScope = parameter.getDeclarationScope(); PsiParameterList parameterList; if (declarationScope instanceof PsiMethod && parameter.getParent() == (parameterList = ((PsiMethod) declarationScope).getParameterList())) { PsiMethod method = (PsiMethod) declarationScope; final int parameterIndex = parameterList.getParameterIndex(parameter); ContainerUtil.addAll(all, modifierList.getAnnotations()); SuperMethodsSearch.search(method, null, true, true) .forEach( new Processor<MethodSignatureBackedByPsiMethod>() { public boolean process(final MethodSignatureBackedByPsiMethod superMethod) { PsiParameter superParameter = superMethod.getMethod().getParameterList().getParameters()[parameterIndex]; PsiModifierList modifierList = superParameter.getModifierList(); if (modifierList != null) { ContainerUtil.addAll(all, modifierList.getAnnotations()); } return true; } }); return all.toArray(new PsiAnnotation[all.size()]); } } return modifierList.getAnnotations(); }
@NotNull private List<AnnotationData> doCollect( @NotNull PsiModifierListOwner listOwner, boolean onlyWritable) { final List<PsiFile> files = findExternalAnnotationsFiles(listOwner); if (files == null) { return NO_DATA; } SmartList<AnnotationData> result = new SmartList<AnnotationData>(); String externalName = getExternalName(listOwner, false); if (externalName == null) return NO_DATA; for (PsiFile file : files) { if (!file.isValid()) continue; if (onlyWritable && !file.isWritable()) continue; MostlySingularMultiMap<String, AnnotationData> fileData = getDataFromFile(file); ContainerUtil.addAll(result, fileData.get(externalName)); } if (result.isEmpty()) { return NO_DATA; } result.trimToSize(); return result; }
private String[] suggestVariableNameByType( PsiType type, final VariableKind variableKind, boolean correctKeywords) { String longTypeName = getLongTypeName(type); CodeStyleSettings.TypeToNameMap map = getMapByVariableKind(variableKind); if (map != null && longTypeName != null) { if (type.equals(PsiType.NULL)) { longTypeName = CommonClassNames.JAVA_LANG_OBJECT; } String name = map.nameByType(longTypeName); if (name != null && isIdentifier(name)) { return new String[] {name}; } } Collection<String> suggestions = new LinkedHashSet<String>(); suggestNamesForCollectionInheritors(type, variableKind, suggestions, correctKeywords); suggestNamesFromGenericParameters(type, variableKind, suggestions, correctKeywords); String typeName = normalizeTypeName(getTypeName(type)); if (typeName != null) { ContainerUtil.addAll( suggestions, getSuggestionsByName( typeName, variableKind, type instanceof PsiArrayType, correctKeywords)); } return ArrayUtil.toStringArray(suggestions); }
/** @return were javadoc params used */ public static void collectAnnotationValues( final Map<String, Collection<String>> results, PsiMethod[] psiMethods, PsiClass... classes) { final Set<String> test = new HashSet<>(1); test.add(TEST_ANNOTATION_FQN); ContainerUtil.addAll(test, CONFIG_ANNOTATIONS_FQN); if (psiMethods != null) { for (final PsiMethod psiMethod : psiMethods) { ApplicationManager.getApplication() .runReadAction( () -> appendAnnotationAttributeValues( results, AnnotationUtil.findAnnotation(psiMethod, test), psiMethod)); } } else { for (final PsiClass psiClass : classes) { ApplicationManager.getApplication() .runReadAction( () -> { if (psiClass != null && hasTest(psiClass)) { appendAnnotationAttributeValues( results, AnnotationUtil.findAnnotation(psiClass, test), psiClass); PsiMethod[] methods = psiClass.getMethods(); for (PsiMethod method : methods) { if (method != null) { appendAnnotationAttributeValues( results, AnnotationUtil.findAnnotation(method, test), method); } } } }); } } }
private Object[] processPackage(final PsiPackage aPackage) { final ArrayList<Object> list = new ArrayList<Object>(); final int startOffset = StringUtil.isEmpty(aPackage.getName()) ? 0 : aPackage.getQualifiedName().length() + 1; final GlobalSearchScope scope = getScope(); for (final PsiPackage subPackage : aPackage.getSubPackages(scope)) { final String shortName = subPackage.getQualifiedName().substring(startOffset); if (JavaPsiFacade.getInstance(subPackage.getProject()) .getNameHelper() .isIdentifier(shortName)) { list.add(subPackage); } } final PsiClass[] classes = aPackage.getClasses(scope); final Map<CustomizableReferenceProvider.CustomizationKey, Object> options = getOptions(); if (options != null) { final boolean instantiatable = JavaClassReferenceProvider.INSTANTIATABLE.getBooleanValue(options); final boolean concrete = JavaClassReferenceProvider.CONCRETE.getBooleanValue(options); final boolean notInterface = JavaClassReferenceProvider.NOT_INTERFACE.getBooleanValue(options); final boolean notEnum = JavaClassReferenceProvider.NOT_ENUM.getBooleanValue(options); final ClassKind classKind = getClassKind(); for (PsiClass clazz : classes) { if (isClassAccepted(clazz, classKind, instantiatable, concrete, notInterface, notEnum)) { list.add(clazz); } } } else { ContainerUtil.addAll(list, classes); } return list.toArray(); }
public GrInplaceConstantIntroducer( GrIntroduceContext context, OccurrencesChooser.ReplaceChoice choice) { super(IntroduceConstantHandler.REFACTORING_NAME, choice, context); myContext = context; myPanel = new GrInplaceIntroduceConstantPanel(); GrVariable localVar = GrIntroduceHandlerBase.resolveLocalVar(context); if (localVar != null) { ArrayList<String> result = ContainerUtil.newArrayList(localVar.getName()); GrExpression initializer = localVar.getInitializerGroovy(); if (initializer != null) { ContainerUtil.addAll( result, GroovyNameSuggestionUtil.suggestVariableNames( initializer, new GroovyInplaceFieldValidator(context), true)); } mySuggestedNames = ArrayUtil.toStringArray(result); } else { GrExpression expression = context.getExpression(); assert expression != null; mySuggestedNames = GroovyNameSuggestionUtil.suggestVariableNames( expression, new GroovyInplaceFieldValidator(context), true); } }
private static UsageGroupingRule[] getActiveGroupingRules(final Project project) { final UsageGroupingRuleProvider[] providers = Extensions.getExtensions(UsageGroupingRuleProvider.EP_NAME); List<UsageGroupingRule> list = new ArrayList<UsageGroupingRule>(providers.length); for (UsageGroupingRuleProvider provider : providers) { ContainerUtil.addAll(list, provider.getActiveRules(project)); } Collections.sort( list, new Comparator<UsageGroupingRule>() { @Override public int compare(final UsageGroupingRule o1, final UsageGroupingRule o2) { return getRank(o1) - getRank(o2); } private int getRank(final UsageGroupingRule rule) { if (rule instanceof OrderableUsageGroupingRule) { return ((OrderableUsageGroupingRule) rule).getRank(); } return Integer.MAX_VALUE; } }); return list.toArray(new UsageGroupingRule[list.size()]); }
@NotNull public Object[] getVariants() { final AntElement element = getElement(); if (element instanceof AntAntImpl) { final PsiFile psiFile = ((AntAntImpl) element).getCalledAntFile(); if (psiFile != null) { AntFile antFile; if (psiFile instanceof AntFile) { antFile = (AntFile) psiFile; } else { antFile = AntSupport.getAntFile(psiFile); } final AntProject project = (antFile == null) ? null : antFile.getAntProject(); if (project != null) { return project.getTargets(); } } } List<AntTarget> result = new ArrayList<AntTarget>(); final AntProject project = element.getAntProject(); final AntTarget[] targets = project.getTargets(); for (final AntTarget target : targets) { if (target != element) { result.add(target); } } ContainerUtil.addAll(result, project.getImportedTargets()); return result.toArray(); }
private boolean findUsagesForElement( PsiNamedElement element, List<UsageInfo> result, final boolean searchInStringsAndComments, final boolean searchInNonJavaFiles, List<UnresolvableCollisionUsageInfo> unresolvedUsages, Map<PsiElement, String> allRenames) { final String newName = getNewName(element); if (newName != null) { final LinkedHashMap<PsiNamedElement, String> renames = new LinkedHashMap<PsiNamedElement, String>(); renames.putAll(myRenames); if (allRenames != null) { for (PsiElement psiElement : allRenames.keySet()) { if (psiElement instanceof PsiNamedElement) { renames.put((PsiNamedElement) psiElement, allRenames.get(psiElement)); } } } final UsageInfo[] usages = RenameUtil.findUsages( element, newName, searchInStringsAndComments, searchInNonJavaFiles, renames); for (final UsageInfo usage : usages) { if (usage instanceof UnresolvableCollisionUsageInfo) { if (unresolvedUsages != null) { unresolvedUsages.add((UnresolvableCollisionUsageInfo) usage); } return false; } } ContainerUtil.addAll(result, usages); } return true; }
public AddMethodFix( @NonNls @NotNull String methodText, @NotNull PsiClass implClass, @NotNull String... exceptions) { this(createMethod(methodText, implClass), implClass); ContainerUtil.addAll(myExceptions, exceptions); }
private void suggestNamesFromGenericParameters( final PsiType type, final VariableKind variableKind, final Collection<String> suggestions, boolean correctKeywords) { if (!(type instanceof PsiClassType)) { return; } StringBuilder fullNameBuilder = new StringBuilder(); final PsiType[] parameters = ((PsiClassType) type).getParameters(); for (PsiType parameter : parameters) { if (parameter instanceof PsiClassType) { final String typeName = normalizeTypeName(getTypeName(parameter)); if (typeName != null) { fullNameBuilder.append(typeName); } } } String baseName = normalizeTypeName(getTypeName(type)); if (baseName != null) { fullNameBuilder.append(baseName); ContainerUtil.addAll( suggestions, getSuggestionsByName(fullNameBuilder.toString(), variableKind, false, correctKeywords)); } }
@Override @Nullable public Collection<PsiImportStatementBase> findRedundantImports(final PsiJavaFile file) { final PsiImportList importList = file.getImportList(); if (importList == null) return null; final PsiImportStatementBase[] imports = importList.getAllImportStatements(); if (imports.length == 0) return null; Set<PsiImportStatementBase> allImports = new THashSet<PsiImportStatementBase>(Arrays.asList(imports)); final Collection<PsiImportStatementBase> redundant; if (FileTypeUtils.isInServerPageFile(file)) { // remove only duplicate imports redundant = ContainerUtil.newIdentityTroveSet(); ContainerUtil.addAll(redundant, imports); redundant.removeAll(allImports); for (PsiImportStatementBase importStatement : imports) { if (importStatement instanceof JspxImportStatement && importStatement.isForeignFileImport()) { redundant.remove(importStatement); } } } else { redundant = allImports; final List<PsiFile> roots = file.getViewProvider().getAllFiles(); for (PsiElement root : roots) { root.accept( new JavaRecursiveElementWalkingVisitor() { @Override public void visitReferenceElement(PsiJavaCodeReferenceElement reference) { if (!reference.isQualified()) { final JavaResolveResult resolveResult = reference.advancedResolve(false); if (!inTheSamePackage(file, resolveResult.getElement())) { final PsiElement resolveScope = resolveResult.getCurrentFileResolveScope(); if (resolveScope instanceof PsiImportStatementBase) { final PsiImportStatementBase importStatementBase = (PsiImportStatementBase) resolveScope; redundant.remove(importStatementBase); } } } super.visitReferenceElement(reference); } private boolean inTheSamePackage(PsiJavaFile file, PsiElement element) { if (element instanceof PsiClass && ((PsiClass) element).getContainingClass() == null) { final PsiFile containingFile = element.getContainingFile(); if (containingFile instanceof PsiJavaFile) { return Comparing.strEqual( file.getPackageName(), ((PsiJavaFile) containingFile).getPackageName()); } } return false; } }); } } return redundant; }
/** * Filter the specified collection of classes to return only ones that contain any of the * specified values in the specified annotation parameter. For example, this method can be used to * return all classes that contain all tesng annotations that are in the groups 'foo' or 'bar'. */ public static Map<PsiClass, Collection<PsiMethod>> filterAnnotations( String parameter, Set<String> values, Collection<PsiClass> classes) { Map<PsiClass, Collection<PsiMethod>> results = new HashMap<>(); Set<String> test = new HashSet<>(1); test.add(TEST_ANNOTATION_FQN); ContainerUtil.addAll(test, CONFIG_ANNOTATIONS_FQN); for (PsiClass psiClass : classes) { if (isBrokenPsiClass(psiClass)) continue; PsiAnnotation annotation; try { annotation = AnnotationUtil.findAnnotation(psiClass, test); } catch (Exception e) { LOGGER.error( "Exception trying to findAnnotation on " + psiClass.getClass().getName() + ".\n\n" + e.getMessage()); annotation = null; } if (annotation != null) { if (isAnnotatedWithParameter(annotation, parameter, values)) { results.put(psiClass, new LinkedHashSet<>()); } } else { Collection<String> matches = extractAnnotationValuesFromJavaDoc(getTextJavaDoc(psiClass), parameter); for (String s : matches) { if (values.contains(s)) { results.put(psiClass, new LinkedHashSet<>()); break; } } } // we already have the class, no need to look through its methods PsiMethod[] methods = psiClass.getMethods(); for (PsiMethod method : methods) { if (method != null) { annotation = AnnotationUtil.findAnnotation(method, test); if (annotation != null) { if (isAnnotatedWithParameter(annotation, parameter, values)) { if (results.get(psiClass) == null) results.put(psiClass, new LinkedHashSet<>()); results.get(psiClass).add(method); } } else { Collection<String> matches = extractAnnotationValuesFromJavaDoc(getTextJavaDoc(psiClass), parameter); for (String s : matches) { if (values.contains(s)) { results.get(psiClass).add(method); } } } } } } return results; }
private Set<Object> addPaths(Object[] elements) { Set<Object> set = new HashSet<Object>(); if (elements != null) { ContainerUtil.addAll(set, elements); } return addPaths(set); }
@Nullable private List<Task> getIssuesFromRepositories( @Nullable String request, int max, long since, boolean forceRequest, @NotNull final ProgressIndicator cancelled) { List<Task> issues = null; for (final TaskRepository repository : getAllRepositories()) { if (!repository.isConfigured() || (!forceRequest && myBadRepositories.contains(repository))) { continue; } try { Task[] tasks = repository.getIssues(request, max, since, cancelled); myBadRepositories.remove(repository); if (issues == null) issues = new ArrayList<Task>(tasks.length); if (!repository.isSupported(TaskRepository.NATIVE_SEARCH) && request != null) { List<Task> filteredTasks = TaskSearchSupport.filterTasks(request, ContainerUtil.list(tasks)); ContainerUtil.addAll(issues, filteredTasks); } else { ContainerUtil.addAll(issues, tasks); } } catch (ProcessCanceledException ignored) { // OK } catch (Exception e) { String reason = ""; // Fix to IDEA-111810 if (e.getClass() == Exception.class) { // probably contains some message meaningful to end-user reason = e.getMessage(); } //noinspection InstanceofCatchParameter if (e instanceof SocketTimeoutException) { LOG.warn("Socket timeout from " + repository); } else { LOG.warn("Cannot connect to " + repository, e); } myBadRepositories.add(repository); if (forceRequest) { notifyAboutConnectionFailure(repository, reason); } } } return issues; }
public void installNorthComponents(final Project project) { ContainerUtil.addAll( myNorthComponents, Extensions.getExtensions(IdeRootPaneNorthExtension.EP_NAME, project)); for (IdeRootPaneNorthExtension northComponent : myNorthComponents) { myNorthPanel.add(northComponent.getComponent()); northComponent.uiSettingsChanged(myUISettings); } }
@Override @NotNull protected List<FileType> getAllFilterValues() { List<FileType> elements = new ArrayList<FileType>(); ContainerUtil.addAll(elements, FileTypeManager.getInstance().getRegisteredFileTypes()); Collections.sort(elements, FileTypeComparator.INSTANCE); return elements; }
private static UsageFilteringRule[] getActiveFilteringRules(final Project project) { final UsageFilteringRuleProvider[] providers = Extensions.getExtensions(UsageFilteringRuleProvider.EP_NAME); List<UsageFilteringRule> list = new ArrayList<UsageFilteringRule>(providers.length); for (UsageFilteringRuleProvider provider : providers) { ContainerUtil.addAll(list, provider.getActiveRules(project)); } return list.toArray(new UsageFilteringRule[list.size()]); }
private AnAction[] createGroupingActions() { final UsageGroupingRuleProvider[] providers = Extensions.getExtensions(UsageGroupingRuleProvider.EP_NAME); List<AnAction> list = new ArrayList<AnAction>(providers.length); for (UsageGroupingRuleProvider provider : providers) { ContainerUtil.addAll(list, provider.createGroupingActions(this)); } return list.toArray(new AnAction[list.size()]); }
public EditorWithProviderComposite[] getEditorsComposites() { List<EditorWithProviderComposite> res = new ArrayList<EditorWithProviderComposite>(); for (final EditorWindow myWindow : myWindows) { final EditorWithProviderComposite[] editors = myWindow.getEditors(); ContainerUtil.addAll(res, editors); } return res.toArray(new EditorWithProviderComposite[res.size()]); }
private NameSuggestionsField createNameField(GrVariable var) { List<String> names = new ArrayList<String>(); if (var != null) { names.add(var.getName()); } ContainerUtil.addAll(names, suggestNames()); return new NameSuggestionsField( ArrayUtil.toStringArray(names), myProject, GroovyFileType.GROOVY_FILE_TYPE); }
private static ModuleConfigurationEditorProvider[] collectProviders(@NotNull Module module) { List<ModuleConfigurationEditorProvider> result = new ArrayList<>(); result.addAll(ServiceKt.getComponents(module, ModuleConfigurationEditorProvider.class)); for (ModuleConfigurationEditorProvider component : result) { reportDeprecatedModuleEditor(component.getClass()); } ContainerUtil.addAll( result, Extensions.getExtensions(ModuleConfigurationEditorProvider.EP_NAME, module)); return result.toArray(new ModuleConfigurationEditorProvider[result.size()]); }