@NotNull private InlineProgressIndicator createInlineDelegate( @NotNull TaskInfo info, @NotNull ProgressIndicatorEx original, final boolean compact) { final Collection<InlineProgressIndicator> inlines = myOriginal2Inlines.get(original); if (inlines != null) { for (InlineProgressIndicator eachInline : inlines) { if (eachInline.isCompact() == compact) return eachInline; } } final InlineProgressIndicator inline = new MyInlineProgressIndicator(compact, info, original); myInline2Original.put(inline, original); myOriginal2Inlines.put(original, inline); if (compact) { inline .getComponent() .addMouseListener( new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { handle(e); } @Override public void mouseReleased(MouseEvent e) { handle(e); } }); } return inline; }
private ProgressIndicatorEx removeFromMaps(@NotNull InlineProgressIndicator progress) { final ProgressIndicatorEx original = myInline2Original.get(progress); myInline2Original.remove(progress); myOriginal2Inlines.remove(original, progress); if (myOriginal2Inlines.get(original) == null) { final int originalIndex = myOriginals.indexOf(original); myOriginals.remove(originalIndex); myInfos.remove(originalIndex); } return original; }
public static void processFiles(final List<FileInfo> fileInfos, @Nullable String changelist) { FileInfo[] copy = fileInfos.toArray(new FileInfo[fileInfos.size()]); MultiValuesMap<HandleType, VirtualFile> handleTypeToFile = new MultiValuesMap<HandleType, VirtualFile>(); for (FileInfo fileInfo : copy) { handleTypeToFile.put(fileInfo.getSelectedHandleType(), fileInfo.getFile()); } for (HandleType handleType : handleTypeToFile.keySet()) { handleType.processFiles( handleTypeToFile.get(handleType), changelist == null ? handleType.getDefaultChangelist() : changelist); } for (FileInfo fileInfo : copy) { if (!fileInfo.getFile().exists() || fileInfo.getFile().isWritable()) { fileInfos.remove(fileInfo); } } }
@Nullable("null means DFA analysis has failed (too complex to analyze)") public static Collection<PsiExpression> getCachedVariableValues( @Nullable final PsiVariable variable, @Nullable final PsiElement context) { if (variable == null || context == null) return Collections.emptyList(); CachedValue<MultiValuesMap<PsiVariable, PsiExpression>> cachedValue = context.getUserData(DFA_VARIABLE_INFO_KEY); if (cachedValue == null) { final PsiElement codeBlock = DfaPsiUtil.getEnclosingCodeBlock(variable, context); cachedValue = CachedValuesManager.getManager(context.getProject()) .createCachedValue( new CachedValueProvider<MultiValuesMap<PsiVariable, PsiExpression>>() { @Override public Result<MultiValuesMap<PsiVariable, PsiExpression>> compute() { final MultiValuesMap<PsiVariable, PsiExpression> result; if (codeBlock == null) { result = null; } else { final ValuableInstructionVisitor visitor = new ValuableInstructionVisitor(context); RunnerResult runnerResult = new ValuableDataFlowRunner().analyzeMethod(codeBlock, visitor); if (runnerResult == RunnerResult.OK) { result = visitor.myValues; } else { result = TOO_COMPLEX; } } return new Result<MultiValuesMap<PsiVariable, PsiExpression>>( result, variable); } }, false); context.putUserData(DFA_VARIABLE_INFO_KEY, cachedValue); } final MultiValuesMap<PsiVariable, PsiExpression> value = cachedValue.getValue(); if (value == TOO_COMPLEX) return null; final Collection<PsiExpression> expressions = value == null ? null : value.get(variable); return expressions == null ? Collections.<PsiExpression>emptyList() : expressions; }