Esempio n. 1
0
  @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;
  }
Esempio n. 2
0
 private static MultiValuesMap<String, BaseInjection> createInjectionMap(
     final Collection<BaseInjection> injections) {
   final MultiValuesMap<String, BaseInjection> existingMap =
       new MultiValuesMap<String, BaseInjection>();
   for (BaseInjection injection : injections) {
     for (InjectionPlace place : injection.getInjectionPlaces()) {
       existingMap.put(place.getText(), injection);
     }
   }
   return existingMap;
 }
Esempio n. 3
0
  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;
  }
Esempio n. 4
0
 @Override
 public DfaInstructionState[] visitPush(
     PushInstruction instruction, DataFlowRunner runner, DfaMemoryState memState) {
   if (myContext == instruction.getPlace()) {
     final Map<DfaVariableValue, DfaVariableState> map =
         ((ValuableDataFlowRunner.MyDfaMemoryState) memState).getVariableStates();
     for (Map.Entry<DfaVariableValue, DfaVariableState> entry : map.entrySet()) {
       ValuableDataFlowRunner.ValuableDfaVariableState state =
           (ValuableDataFlowRunner.ValuableDfaVariableState) entry.getValue();
       DfaVariableValue variableValue = entry.getKey();
       final PsiExpression psiExpression = state.myExpression;
       if (psiExpression != null && variableValue.getQualifier() == null) {
         myValues.put(variableValue.getPsiVariable(), psiExpression);
       }
     }
     DfaValue value = instruction.getValue();
     if (value instanceof DfaVariableValue
         && ((DfaVariableValue) value).getQualifier() == null) {
       if (memState.isNotNull((DfaVariableValue) value)) {
         myNotNulls.add(((DfaVariableValue) value).getPsiVariable());
       }
       if (memState.isNull(value)) {
         myNulls.add(((DfaVariableValue) value).getPsiVariable());
       }
     }
   }
   return super.visitPush(instruction, runner, memState);
 }
 static void importInjections(
     final Collection<BaseInjection> existingInjections,
     final Collection<BaseInjection> importingInjections,
     final Collection<BaseInjection> originalInjections,
     final Collection<BaseInjection> newInjections) {
   final MultiValuesMap<InjectionPlace, BaseInjection> placeMap =
       new MultiValuesMap<InjectionPlace, BaseInjection>();
   for (BaseInjection exising : existingInjections) {
     for (InjectionPlace place : exising.getInjectionPlaces()) {
       placeMap.put(place, exising);
     }
   }
   main:
   for (BaseInjection other : importingInjections) {
     final List<BaseInjection> matchingInjections =
         ContainerUtil.concat(
             other.getInjectionPlaces(),
             new Function<InjectionPlace, Collection<? extends BaseInjection>>() {
               public Collection<? extends BaseInjection> fun(final InjectionPlace o) {
                 final Collection<BaseInjection> collection = placeMap.get(o);
                 return collection == null ? Collections.<BaseInjection>emptyList() : collection;
               }
             });
     if (matchingInjections.isEmpty()) {
       newInjections.add(other);
     } else {
       BaseInjection existing = null;
       for (BaseInjection injection : matchingInjections) {
         if (injection.equals(other)) continue main;
         if (existing == null && injection.sameLanguageParameters(other)) {
           existing = injection;
         }
       }
       if (existing == null) continue main; // skip!! language changed
       final BaseInjection newInjection = existing.copy();
       newInjection.mergeOriginalPlacesFrom(other, true);
       if (!newInjection.equals(existing)) {
         originalInjections.add(existing);
         newInjections.add(newInjection);
       }
     }
   }
 }
  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);
      }
    }
  }
Esempio n. 7
0
 @Override
 public void dispose() {
   setRefreshVisible(false);
   InlineProgressIndicator[] indicators =
       getCurrentInlineIndicators().toArray(new InlineProgressIndicator[0]);
   for (InlineProgressIndicator indicator : indicators) {
     Disposer.dispose(indicator);
   }
   myInline2Original.clear();
   myOriginal2Inlines.clear();
 }
Esempio n. 8
0
  @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;
  }