@Nullable private static IProperty getResolvedProperty(@NotNull final XmlAttributeValue codeValue) { return CachedValuesManager.getCachedValue(codeValue, KEY, () -> { List<IProperty> allProperties = new SmartList<>(); for (PsiReference nextRef : codeValue.getReferences()) { if (nextRef instanceof PsiPolyVariantReference) { Arrays.stream(((PsiPolyVariantReference) nextRef).multiResolve(false)) .filter(ResolveResult::isValidResult) .map(ResolveResult::getElement) .map(o -> ObjectUtils.tryCast(o, IProperty.class)) .filter(Objects::nonNull) .forEach(allProperties::add); } else { Optional.ofNullable(nextRef.resolve()) .map(o -> ObjectUtils.tryCast(o, IProperty.class)) .ifPresent(allProperties::add); } } IProperty theChosenOne = chooseForLocale(allProperties); return new CachedValueProvider.Result<>(theChosenOne, PsiModificationTracker.MODIFICATION_COUNT); }); }
@NotNull @Override protected List<PsiElement> getPsiElementsToProcess() { return ApplicationManager.getApplication().runReadAction(new Computable<List<PsiElement>>() { @Override public List<PsiElement> compute() { final PsiFile file = PsiManager.getInstance(project).findFile(myFile); if (file == null) { return Collections.emptyList(); } final FileViewProvider viewProvider = file.getViewProvider(); final List<PsiElement> elementsToProcess = new SmartList<PsiElement>(); for (Language lang : viewProvider.getLanguages()) { elementsToProcess.add(viewProvider.getPsi(lang)); } return elementsToProcess; } }); }
@SuppressWarnings("ForLoopReplaceableByForEach") public static <T extends DomElement> List<T> getChildrenOf(DomElement parent, final Class<T> type) { final List<T> list = new SmartList<T>(); List<? extends AbstractDomChildrenDescription> descriptions = parent.getGenericInfo().getChildrenDescriptions(); for (int i = 0, descriptionsSize = descriptions.size(); i < descriptionsSize; i++) { AbstractDomChildrenDescription description = descriptions.get(i); if (description.getType() instanceof Class && type.isAssignableFrom((Class<?>)description.getType())) { List<T> values = (List<T>)description.getValues(parent); for (int j = 0, valuesSize = values.size(); j < valuesSize; j++) { T value = values.get(j); if (value.exists()) { list.add(value); } } } } return list; }
@NotNull public static List<LineMarkerInfo> merge(@NotNull List<MergeableLineMarkerInfo> markers) { List<LineMarkerInfo> result = new SmartList<LineMarkerInfo>(); for (int i = 0; i < markers.size(); i++) { MergeableLineMarkerInfo marker = markers.get(i); List<MergeableLineMarkerInfo> toMerge = new SmartList<MergeableLineMarkerInfo>(); for (int k = markers.size() - 1; k > i; k--) { MergeableLineMarkerInfo current = markers.get(k); if (marker.canMergeWith(current)) { toMerge.add(0, current); markers.remove(k); } } if (toMerge.isEmpty()) { result.add(marker); } else { toMerge.add(0, marker); result.add(new MyLineMarkerInfo(toMerge)); } } return result; }
@NotNull @Override public <T extends BeforeRunTask> List<T> getBeforeRunTasks(RunConfiguration settings, Key<T> taskProviderID) { if (settings instanceof WrappingRunConfiguration) { return getBeforeRunTasks(((WrappingRunConfiguration)settings).getPeer(), taskProviderID); } List<BeforeRunTask> tasks = myConfigurationToBeforeTasksMap.get(settings); if (tasks == null) { tasks = getBeforeRunTasks(settings); myConfigurationToBeforeTasksMap.put(settings, tasks); } List<T> result = new SmartList<T>(); for (BeforeRunTask task : tasks) { if (task.getProviderId() == taskProviderID) { //noinspection unchecked result.add((T)task); } } return result; }
public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull final InspectionManager manager, final boolean isOnTheFly) { if (!(file instanceof PropertiesFile)) return null; final List<IProperty> properties = ((PropertiesFile)file).getProperties(); final List<ProblemDescriptor> descriptors = new SmartList<ProblemDescriptor>(); for (IProperty property : properties) { ProgressManager.checkCanceled(); final PropertyImpl propertyImpl = (PropertyImpl)property; for (ASTNode node : ContainerUtil.ar(propertyImpl.getKeyNode(), propertyImpl.getValueNode())) { if (node != null) { PsiElement key = node.getPsi(); TextRange textRange = getTrailingSpaces(key, myIgnoreVisibleSpaces); if (textRange != null) { descriptors.add(manager.createProblemDescriptor(key, textRange, "Trailing spaces", ProblemHighlightType.GENERIC_ERROR_OR_WARNING, true, new RemoveTrailingSpacesFix(myIgnoreVisibleSpaces))); } } } } return descriptors.toArray(new ProblemDescriptor[descriptors.size()]); }
@NotNull private List<AnnotationData> doCollect(@NotNull PsiModifierListOwner listOwner, boolean onlyWritable) { String externalName = getExternalName(listOwner, false); if (externalName == null) return NO_DATA; List<PsiFile> files = findExternalAnnotationsFiles(listOwner); if (files == null) return NO_DATA; SmartList<AnnotationData> result = new SmartList<AnnotationData>(); 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; }
/** * Template configuration is not included */ @Override @NotNull public List<RunConfiguration> getConfigurationsList(@NotNull ConfigurationType type) { List<RunConfiguration> result = null; for (RunnerAndConfigurationSettings settings : getSortedConfigurations()) { RunConfiguration configuration = settings.getConfiguration(); if (type.getId().equals(configuration.getType().getId())) { if (result == null) { result = new SmartList<RunConfiguration>(); } result.add(configuration); } } return ContainerUtil.notNullize(result); }
public VariableResolverProcessor(@NotNull PsiJavaCodeReferenceElement place, @NotNull PsiFile placeFile) { super(place.getReferenceName(), ourFilter, new PsiConflictResolver[]{new JavaVariableConflictResolver()}, new SmartList<CandidateInfo>(), place, placeFile); PsiClass access = null; PsiElement qualifier = place.getQualifier(); if (qualifier instanceof PsiExpression) { final JavaResolveResult accessClass = PsiUtil.getAccessObjectClass((PsiExpression)qualifier); final PsiElement element = accessClass.getElement(); if (element instanceof PsiTypeParameter) { PsiElementFactory factory = JavaPsiFacade.getInstance(placeFile.getProject()).getElementFactory(); final PsiClassType type = factory.createType((PsiTypeParameter)element); final PsiType accessType = accessClass.getSubstitutor().substitute(type); if (accessType instanceof PsiArrayType) { LanguageLevel languageLevel = PsiUtil.getLanguageLevel(placeFile); access = factory.getArrayClass(languageLevel); } else if (accessType instanceof PsiClassType) { access = ((PsiClassType)accessType).resolve(); } } else if (element instanceof PsiClass) { access = (PsiClass)element; } } myAccessClass = access; }
private void add(@NotNull Element state, @Nullable ProgramRunner runner, @Nullable T data) throws InvalidDataException { if (runner == null) { if (unloadedSettings == null) { unloadedSettings = new SmartList<Element>(); } unloadedSettings.add(state); return; } if (data != null) { ((JDOMExternalizable)data).readExternal(state); } settings.put(runner, data); loadedIds.add(runner.getRunnerId()); }
@NotNull public static List<Pair<Breakpoint, Event>> getEventDescriptors(SuspendContextImpl suspendContext) { DebuggerManagerThreadImpl.assertIsManagerThread(); if(suspendContext == null) { return Collections.emptyList(); } final EventSet events = suspendContext.getEventSet(); if(events == null) { return Collections.emptyList(); } final List<Pair<Breakpoint, Event>> eventDescriptors = new SmartList<Pair<Breakpoint, Event>>(); final RequestManagerImpl requestManager = suspendContext.getDebugProcess().getRequestsManager(); for (final Event event : events) { final Requestor requestor = requestManager.findRequestor(event.request()); if (requestor instanceof Breakpoint) { eventDescriptors.add(Pair.create((Breakpoint)requestor, event)); } } return eventDescriptors; }
public static List<JavaPsiClassReferenceElement> createClassLookupItems(final PsiClass psiClass, boolean withInners, InsertHandler<JavaPsiClassReferenceElement> insertHandler, Condition<PsiClass> condition) { List<JavaPsiClassReferenceElement> result = new SmartList<JavaPsiClassReferenceElement>(); if (condition.value(psiClass)) { result.add(AllClassesGetter.createLookupItem(psiClass, insertHandler)); } String name = psiClass.getName(); if (withInners && name != null) { for (PsiClass inner : psiClass.getInnerClasses()) { if (inner.hasModifierProperty(PsiModifier.STATIC)) { for (JavaPsiClassReferenceElement lookupInner : createClassLookupItems(inner, true, insertHandler, condition)) { String forced = lookupInner.getForcedPresentableName(); String qualifiedName = name + "." + (forced != null ? forced : inner.getName()); lookupInner.setForcedPresentableName(qualifiedName); lookupInner.setLookupString(qualifiedName); result.add(lookupInner); } } } } return result; }
@Nullable private static List<PsiMethod> selectMethod(final PsiMethod[] methods, final Trinity<PsiClass, PsiFile, String> previousLineResult) { if (previousLineResult == null || previousLineResult.getThird() == null) return null; final List<PsiMethod> result = new SmartList<PsiMethod>(); for (final PsiMethod method : methods) { method.accept(new JavaRecursiveElementVisitor() { @Override public void visitCallExpression(PsiCallExpression callExpression) { final PsiMethod resolved = callExpression.resolveMethod(); if (resolved != null) { if (resolved.getName().equals(previousLineResult.getThird())) { result.add(method); } } } }); } return result; }
@NotNull @Override public ProjectTemplate[] createTemplates(@Nullable String group, WizardContext context) { // myGroups contains only not-null keys if (group == null) { return ProjectTemplate.EMPTY_ARRAY; } List<ProjectTemplate> templates = null; for (Pair<URL, ClassLoader> url : myGroups.getValue().get(group)) { try { for (String child : UrlUtil.getChildrenRelativePaths(url.first)) { if (child.endsWith(ZIP)) { if (templates == null) { templates = new SmartList<ProjectTemplate>(); } templates.add(new LocalArchivedTemplate(new URL(url.first.toExternalForm() + '/' + child), url.second)); } } } catch (IOException e) { LOG.error(e); } } return ContainerUtil.isEmpty(templates) ? ProjectTemplate.EMPTY_ARRAY : templates.toArray(new ProjectTemplate[templates.size()]); }
private void updateBreakpoints(@NotNull Document document) { Collection<XLineBreakpointImpl> breakpoints = myBreakpoints.getKeysByValue(document); if (breakpoints == null) { return; } TIntHashSet lines = new TIntHashSet(); List<XBreakpoint<?>> toRemove = new SmartList<XBreakpoint<?>>(); for (XLineBreakpointImpl breakpoint : breakpoints) { breakpoint.updatePosition(); if (!breakpoint.isValid() || !lines.add(breakpoint.getLine())) { toRemove.add(breakpoint); } } removeBreakpoints(toRemove); }
public void registerProvider(@NonNls @NotNull String[] names, @NotNull ElementPattern filter, boolean caseSensitive, @NotNull PsiReferenceProvider provider, final double priority) { final Map<String, List<ProviderInfo<ElementPattern>>> map = caseSensitive ? myNamesToProvidersMap : myNamesToProvidersMapInsensitive; for (final String attributeName : names) { String key = caseSensitive ? attributeName : attributeName.toLowerCase(); List<ProviderInfo<ElementPattern>> psiReferenceProviders = map.get(key); if (psiReferenceProviders == null) { map.put(key, psiReferenceProviders = new SmartList<ProviderInfo<ElementPattern>>()); } psiReferenceProviders.add(new ProviderInfo<ElementPattern>(provider, filter, priority)); } }
public static Map<String, Map<String, Map<String, List<MavenPluginDescriptor>>>> getDescriptorsMap() { Map<String, Map<String, Map<String, List<MavenPluginDescriptor>>>> res = ourDescriptorsMap; if (res == null) { res = new HashMap<String, Map<String, Map<String, List<MavenPluginDescriptor>>>>(); for (MavenPluginDescriptor pluginDescriptor : MavenPluginDescriptor.EP_NAME.getExtensions()) { Pair<String, String> pluginId = parsePluginId(pluginDescriptor.mavenId); Map<String, Map<String, List<MavenPluginDescriptor>>> groupMap = MavenUtil.getOrCreate(res, pluginId.second);// pluginId.second is artifactId Map<String, List<MavenPluginDescriptor>> goalsMap = MavenUtil.getOrCreate(groupMap, pluginId.first);// pluginId.first is groupId List<MavenPluginDescriptor> descriptorList = goalsMap.get(pluginDescriptor.goal); if (descriptorList == null) { descriptorList = new SmartList<MavenPluginDescriptor>(); goalsMap.put(pluginDescriptor.goal, descriptorList); } descriptorList.add(pluginDescriptor); } ourDescriptorsMap = res; } return res; }
@NotNull protected static SmartList<HgRevisionNumber> parseParentRevisions(@NotNull String parentsString, @NotNull String currentRevisionString) { SmartList<HgRevisionNumber> parents = new SmartList<HgRevisionNumber>(); if (StringUtil.isEmptyOrSpaces(parentsString)) { // parents shouldn't be empty only if not supported Long revision = Long.valueOf(currentRevisionString); HgRevisionNumber parentRevision = HgRevisionNumber.getLocalInstance(String.valueOf(revision - 1)); parents.add(parentRevision); return parents; } //hg returns parents in the format 'rev:node rev:node ' (note the trailing space) List<String> parentStrings = StringUtil.split(parentsString.trim(), " "); for (String parentString : parentStrings) { List<String> parentParts = StringUtil.split(parentString, ":"); //if revision has only 1 parent and "--debug" argument were added or if appropriate parent template were used, // its second parent has revision number -1 if (Integer.valueOf(parentParts.get(0)) >= 0) { parents.add(HgRevisionNumber.getInstance(parentParts.get(0), parentParts.get(1))); } } return parents; }
@NotNull public Object[] getVariants() { final ProjectFileIndex projectFileIndex = ProjectFileIndex.SERVICE.getInstance(getElement().getProject()); final PropertiesReferenceManager referenceManager = PropertiesReferenceManager.getInstance(getElement().getProject()); final Set<String> bundleNames = new HashSet<String>(); final List<LookupElement> variants = new SmartList<LookupElement>(); PropertiesFileProcessor processor = new PropertiesFileProcessor() { @Override public boolean process(String baseName, PropertiesFile propertiesFile) { if (!bundleNames.add(baseName)) return true; final LookupElementBuilder builder = LookupElementBuilder.create(baseName) .withIcon(AllIcons.Nodes.ResourceBundle); boolean isInContent = projectFileIndex.isInContent(propertiesFile.getVirtualFile()); variants.add(isInContent ? PrioritizedLookupElement.withPriority(builder, Double.MAX_VALUE) : builder); return true; } }; referenceManager.processPropertiesFiles(myElement.getResolveScope(), processor, this); return variants.toArray(new LookupElement[variants.size()]); }
public List<DomStub> getChildrenByName(final CharSequence name, @Nullable final String nsKey) { final List<DomStub> stubs = getChildrenStubs(); if (stubs.isEmpty()) { return Collections.emptyList(); } final String s = nsKey == null ? "" : nsKey; final List<DomStub> result = new SmartList<DomStub>(); //noinspection ForLoopReplaceableByForEach for (int i = 0, size = stubs.size(); i < size; i++) { final DomStub stub = stubs.get(i); if (XmlUtil.getLocalName(stub.getName()).equals(name) && Comparing.equal(s, stub.getNamespaceKey())) { result.add(stub); } } return result; }
private static PsiReference[] createPrefixReferences(XmlAttribute attribute, Pattern pattern) { final Matcher matcher = pattern.matcher(attribute.getValue()); if (matcher.find()) { final List<PsiReference> refs = new SmartList<PsiReference>(); do { final int start = matcher.start(1); if (start >= 0) { refs.add(new PrefixReference(attribute, TextRange.create(start, matcher.end(1)))); } } while (matcher.find()); return refs.toArray(new PsiReference[refs.size()]); } return PsiReference.EMPTY_ARRAY; }
@NotNull private List<BeforeRunTask> readStepsBeforeRun(@Nullable Element child, @NotNull RunnerAndConfigurationSettings settings) { List<BeforeRunTask> result = null; if (child != null) { for (Element methodElement : child.getChildren(OPTION)) { Key<? extends BeforeRunTask> id = getProviderKey(methodElement.getAttributeValue(NAME_ATTR)); BeforeRunTask beforeRunTask = getProvider(id).createTask(settings.getConfiguration()); if (beforeRunTask != null) { beforeRunTask.readExternal(methodElement); if (result == null) { result = new SmartList<BeforeRunTask>(); } result.add(beforeRunTask); } } } return ContainerUtil.notNullize(result); }
@NotNull private <F extends Facet&FacetRootsProvider> Map<VirtualFile, List<Facet>> computeRootToFacetsMap(final FacetTypeId<F> type) { final Module[] modules = myModuleManager.getModules(); final HashMap<VirtualFile, List<Facet>> map = new HashMap<VirtualFile, List<Facet>>(); for (Module module : modules) { final Collection<F> facets = FacetManager.getInstance(module).getFacetsByType(type); for (F facet : facets) { for (VirtualFile root : facet.getFacetRoots()) { List<Facet> list = map.get(root); if (list == null) { list = new SmartList<Facet>(); map.put(root, list); } list.add(facet); } } } return map; }
@NotNull public List<MavenArtifact> findArtifacts(@Nullable String groupId, @Nullable String artifactId, @Nullable String version) { Map<String, List<MavenArtifact>> groupMap = myData.get(groupId); if (groupMap == null) return Collections.emptyList(); List<MavenArtifact> artifacts = groupMap.get(artifactId); if (artifacts == null) return Collections.emptyList(); List<MavenArtifact> res = new SmartList<MavenArtifact>(); for (MavenArtifact artifact : artifacts) { if (Comparing.equal(version, artifact.getVersion())) { res.add(artifact); } } return res; }
@Override public List<T> readValue(Element dataElement) { List<T> list = new SmartList<T>(); for (Element element : dataElement.getChildren()) { if (NULL_ELEMENT.equals(element.getName())) { list.add(null); } else if (myItemTagName.equals(element.getName())) { T item = myItemExternalizer.readValue(element); if (item == null) { LOG.error("Can't create element " + myItemExternalizer); return list; } list.add(item); } } return list; }
@Override @Nullable public List<Pair<PsiElement, TextRange>> getInjectedPsiFiles(@NotNull final PsiElement host) { if (!(host instanceof PsiLanguageInjectionHost) || !((PsiLanguageInjectionHost) host).isValidHost()) { return null; } final PsiElement inTree = InjectedLanguageUtil.loadTree(host, host.getContainingFile()); final List<Pair<PsiElement, TextRange>> result = new SmartList<Pair<PsiElement, TextRange>>(); InjectedLanguageUtil.enumerate(inTree, new PsiLanguageInjectionHost.InjectedPsiVisitor() { @Override public void visit(@NotNull PsiFile injectedPsi, @NotNull List<PsiLanguageInjectionHost.Shred> places) { for (PsiLanguageInjectionHost.Shred place : places) { if (place.getHost() == inTree) { result.add(new Pair<PsiElement, TextRange>(injectedPsi, place.getRangeInsideHost())); } } } }); return result.isEmpty() ? null : result; }
@Override protected CachedValue<PsiReference[]> compute(final PsiElement element, Object p) { return CachedValuesManager.getManager(element.getProject()).createCachedValue(new CachedValueProvider<PsiReference[]>() { public Result<PsiReference[]> compute() { IssueNavigationConfiguration navigationConfiguration = IssueNavigationConfiguration.getInstance(element.getProject()); if (navigationConfiguration == null) { return Result.create(PsiReference.EMPTY_ARRAY, element); } List<PsiReference> refs = null; GlobalPathReferenceProvider provider = myReferenceProvider.get(); CharSequence commentText = StringUtil.newBombedCharSequence(element.getText(), 500); for (IssueNavigationConfiguration.LinkMatch link : navigationConfiguration.findIssueLinks(commentText)) { if (refs == null) refs = new SmartList<PsiReference>(); if (provider == null) { provider = (GlobalPathReferenceProvider)PathReferenceManager.getInstance().getGlobalWebPathReferenceProvider(); myReferenceProvider.lazySet(provider); } provider.createUrlReference(element, link.getTargetUrl(), link.getRange(), refs); } PsiReference[] references = refs != null ? refs.toArray(new PsiReference[refs.size()]) : PsiReference.EMPTY_ARRAY; return new Result<PsiReference[]>(references, element, navigationConfiguration); } }, false); }
@NotNull public AsyncResult<List<T>> create() { int size = asyncResults.size(); if (size == 0) { return AsyncResult.doneList(); } final List<T> results = size == 1 ? new SmartList<T>() : new ArrayList<T>(size); final AsyncResult<List<T>> totalResult = new AsyncResult<List<T>>(asyncResults.size(), results); Consumer<T> resultConsumer = new Consumer<T>() { @Override public void consume(T result) { synchronized (results) { results.add(result); } totalResult.setDone(); } }; for (AsyncResult<T> subResult : asyncResults) { subResult.doWhenDone(resultConsumer).notifyWhenRejected(totalResult); } return totalResult; }
private static String[] makeQualifiedModuleInterfaceNames(XmlTag component, String fqn) { final XmlTag[] children = component.findSubTags("option"); for (XmlTag child : children) { if ("type".equals(child.getAttributeValue("name"))) { final String value = child.getAttributeValue("value"); final SmartList<String> names = new SmartList<String>(); if (value != null) { final String[] moduleTypes = value.split(";"); for (String moduleType : moduleTypes) { names.add(fqn + "#" + moduleType); } } return ArrayUtil.toStringArray(names); } } return new String[]{ fqn }; }
@Override @NotNull public List<? extends DomElement> getValues(@NotNull final DomElement element) { final List<DomElement> result = new SmartList<DomElement>(); final DomInvocationHandler handler = DomManagerImpl.getDomInvocationHandler(element); if (handler != null) { for (int i = 0; i < myCount; i++) { result.add(handler.getFixedChild(Pair.create(this, i)).getProxy()); } } else { for (Collection<JavaMethod> methods : myGetterMethods) { if (methods != null && !methods.isEmpty()) { result.add((DomElement)methods.iterator().next().invoke(element, ArrayUtil.EMPTY_OBJECT_ARRAY)); } } } return result; }
private static List<Pair<LibraryKind, LibraryProperties>> computeKinds(List<VirtualFile> files) { final SmartList<Pair<LibraryKind, LibraryProperties>> result = new SmartList<Pair<LibraryKind, LibraryProperties>>(); final LibraryType<?>[] libraryTypes = LibraryType.EP_NAME.getExtensions(); final LibraryPresentationProvider[] presentationProviders = LibraryPresentationProvider.EP_NAME.getExtensions(); for (LibraryPresentationProvider provider : ContainerUtil.concat(libraryTypes, presentationProviders)) { final LibraryProperties properties = provider.detect(files); if (properties != null) { result.add(Pair.create(provider.getKind(), properties)); } } return result; }
@Nullable public static <T extends PsiElement> T[] getChildrenOfType(@Nullable PsiElement element, @NotNull Class<T> aClass) { if (element == null) return null; List<T> result = null; for (PsiElement child = element.getFirstChild(); child != null; child = child.getNextSibling()) { if (aClass.isInstance(child)) { if (result == null) result = new SmartList<T>(); //noinspection unchecked result.add((T)child); } } return result == null ? null : ArrayUtil.toObjectArray(result, aClass); }
@Override public Collection<BuildTarget<?>> computeDependencies(BuildTargetRegistry targetRegistry, final TargetOutputIndex outputIndex) { final LinkedHashSet<BuildTarget<?>> dependencies = new LinkedHashSet<BuildTarget<?>>(); JpsArtifactUtil.processPackagingElements(myArtifact.getRootElement(), new Processor<JpsPackagingElement>() { @Override public boolean process(JpsPackagingElement element) { if (element instanceof JpsArtifactOutputPackagingElement) { JpsArtifact included = ((JpsArtifactOutputPackagingElement)element).getArtifactReference().resolve(); if (included != null && !included.equals(myArtifact)) { if (!StringUtil.isEmpty(included.getOutputPath())) { dependencies.add(new ArtifactBuildTarget(included)); return false; } } } dependencies.addAll(LayoutElementBuildersRegistry.getInstance().getDependencies(element, outputIndex)); return true; } }); if (!dependencies.isEmpty()) { final List<BuildTarget<?>> additional = new SmartList<BuildTarget<?>>(); for (BuildTarget<?> dependency : dependencies) { if (dependency instanceof ModuleBasedTarget<?>) { final ModuleBasedTarget target = (ModuleBasedTarget)dependency; additional.addAll(targetRegistry.getModuleBasedTargets(target.getModule(), target.isTests()? BuildTargetRegistry.ModuleTargetSelector.TEST : BuildTargetRegistry.ModuleTargetSelector.PRODUCTION)); } } dependencies.addAll(additional); } return dependencies; }
@Override public List<SourcePathAndRootIndex> read(@NotNull DataInput in) throws IOException { List<SourcePathAndRootIndex> result = new SmartList<SourcePathAndRootIndex>(); final DataInputStream stream = (DataInputStream)in; while (stream.available() > 0) { final String path = IOUtil.readUTF(stream); final int index = stream.readInt(); result.add(new SourcePathAndRootIndex(path, index)); } return result; }
public List<BuildChunkTask> markAsFinishedAndGetNextReadyTasks() { List<BuildChunkTask> nextTasks = new SmartList<BuildChunkTask>(); for (BuildChunkTask task : myTasksDependsOnThis) { final boolean removed = task.myNotBuiltDependencies.remove(this); LOG.assertTrue(removed, task.getChunk().toString() + " didn't have " + getChunk().toString()); if (task.isReady()) { nextTasks.add(task); } } return nextTasks; }
public List<RemotePkgInfo> getAllRemotes() { List<RemotePkgInfo> result = new SmartList<RemotePkgInfo>(); if (myRemoteInfo != null) { result.add(myRemoteInfo); } if (myRemotePreviewInfo != null) { result.add(myRemotePreviewInfo); } return result; }
private void registerDescriptor(BuildRootDescriptor descriptor) { List<BuildRootDescriptor> list = myRootToDescriptors.get(descriptor.getRootFile()); if (list == null) { list = new SmartList<BuildRootDescriptor>(); myRootToDescriptors.put(descriptor.getRootFile(), list); } list.add(descriptor); }
private JpsElementCollectionImpl(JpsElementCollectionImpl<E> original) { myChildRole = original.myChildRole; myElements = new SmartList<E>(); myCopyToOriginal = new HashMap<E, E>(); for (E e : original.myElements) { //noinspection unchecked final E copy = (E)e.getBulkModificationSupport().createCopy(); setParent(copy, this); myElements.add(copy); myCopyToOriginal.put(copy, e); } }
@NotNull private static Collection<InternalExternalProjectInfo> load(@NotNull Project project) throws IOException { SmartList<InternalExternalProjectInfo> projects = new SmartList<InternalExternalProjectInfo>(); @SuppressWarnings("unchecked") final File configurationFile = getProjectConfigurationFile(project); if (!configurationFile.isFile()) return projects; DataInputStream in = new DataInputStream(new BufferedInputStream(new FileInputStream(configurationFile))); try { final String storage_version = in.readUTF(); if (!STORAGE_VERSION.equals(storage_version)) return projects; final int size = in.readInt(); ObjectInputStream os = new ObjectInputStream(in); try { for (int i = 0; i < size; i++) { //noinspection unchecked InternalExternalProjectInfo projectDataDataNode = (InternalExternalProjectInfo)os.readObject(); projects.add(projectDataDataNode); } } catch (ClassNotFoundException e) { IOException ioException = new IOException(); ioException.initCause(e); throw ioException; } finally { os.close(); } } finally { in.close(); } return projects; }
public MethodResolverProcessor(PsiClass classConstr, @NotNull PsiExpressionList argumentList, @NotNull PsiElement place, @NotNull PsiFile placeFile) { super(place, placeFile, new PsiConflictResolver[]{new JavaMethodsConflictResolver(argumentList, PsiUtil.getLanguageLevel(placeFile))}, new SmartList<CandidateInfo>()); setIsConstructor(true); setAccessClass(classConstr); setArgumentList(argumentList); }