Java Code Examples for com.intellij.openapi.progress.progressmanager#checkCanceled()

The following examples show how to use com.intellij.openapi.progress.progressmanager#checkCanceled() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ReadMostlyRWLock.java    From consulo with Apache License 2.0 6 votes vote down vote up
public void readLock() {
  checkReadThreadAccess();
  Reader status = R.get();
  throwIfImpatient(status);

  if (tryReadLock(status)) {
    return;
  }
  for (int iter = 0; ; iter++) {
    if (tryReadLock(status)) {
      break;
    }

    ProgressManager.checkCanceled();
    waitABit(status, iter);
  }
}
 
Example 2
Source File: ShelveChangesManager.java    From consulo with Apache License 2.0 6 votes vote down vote up
public List<VirtualFile> gatherPatchFiles(final Collection<VirtualFile> files) {
  final List<VirtualFile> result = new ArrayList<>();

  final LinkedList<VirtualFile> filesQueue = new LinkedList<>(files);
  while (!filesQueue.isEmpty()) {
    ProgressManager.checkCanceled();
    final VirtualFile file = filesQueue.removeFirst();
    if (file.isDirectory()) {
      filesQueue.addAll(Arrays.asList(file.getChildren()));
      continue;
    }
    if (PatchFileType.NAME.equals(file.getFileType().getName())) {
      result.add(file);
    }
  }

  return result;
}
 
Example 3
Source File: UsingNamespaceFix.java    From consulo-csharp with Apache License 2.0 6 votes vote down vote up
@RequiredReadAction
private static <T extends DotNetQualifiedElement> void collect(Set<NamespaceReference> result, Collection<T> element, Condition<T> condition)
{
	for(T type : element)
	{
		String presentableParentQName = type.getPresentableParentQName();
		if(StringUtil.isEmpty(presentableParentQName))
		{
			continue;
		}

		ProgressManager.checkCanceled();

		if(!condition.value(type))
		{
			continue;
		}

		result.add(new NamespaceReference(presentableParentQName, null));
	}
}
 
Example 4
Source File: BashVarProcessor.java    From BashSupport with Apache License 2.0 5 votes vote down vote up
public boolean execute(@NotNull PsiElement psiElement, @NotNull ResolveState resolveState) {
    ProgressManager.checkCanceled();

    if (psiElement instanceof BashVarDef) {
        BashVarDef varDef = (BashVarDef) psiElement;

        if (!varName.equals(varDef.getName()) || startElement == psiElement || startElement.equals(psiElement)) {
            //proceed with the search
            return true;
        }

        PsiElement includeCommand = resolveState.get(resolvingIncludeCommand);

        // we have the same name, so it's a possible hit -> now check the scope
        boolean localVarDef = varDef.isFunctionScopeLocal();
        boolean isValid = checkLocalness && localVarDef
                ? isValidLocalDefinition(varDef)
                : isValidDefinition(varDef, resolveState);

        // if we found a valid local variable definition we must ignore all (otherwise matching) global variable definitions
        ignoreGlobals = ignoreGlobals || (isValid && checkLocalness && localVarDef);

        if (isValid) {
            PsiElement defAnchor = includeCommand != null ? includeCommand : varDef;

            storeResult(varDef, BashPsiUtils.blockNestingLevel(defAnchor), includeCommand);

            if (!localVarDef) {
                globalVariables.add(varDef);
            }

            return collectAllDefinitions;
        }
    }

    return true;
}
 
Example 5
Source File: AsyncFilterRunner.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void runTasks() {
  ApplicationManager.getApplication().assertReadAccessAllowed();
  if (myEditor.isDisposed()) return;

  while (!myQueue.isEmpty()) {
    HighlighterJob highlighter = myQueue.peek();
    if (!DumbService.isDumbAware(highlighter.filter) && DumbService.isDumb(highlighter.myProject)) return;
    while (highlighter.hasUnprocessedLines()) {
      ProgressManager.checkCanceled();
      addLineResult(highlighter.analyzeNextLine());
    }
    LOG.assertTrue(highlighter == myQueue.remove());
  }
}
 
Example 6
Source File: ProjectLevelVcsManagerImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
@Nullable
public AbstractVcs findVcsByName(String name) {
  if (name == null) return null;
  AbstractVcs result = myProject.isDisposed() ? null : AllVcses.getInstance(myProject).getByName(name);
  ProgressManager.checkCanceled();
  return result;
}
 
Example 7
Source File: Unity3dMetaFileProjectViewProvider.java    From consulo-unity3d with Apache License 2.0 5 votes vote down vote up
@Nonnull
@RequiredReadAction
private Collection<AbstractTreeNode> doModify(Collection<AbstractTreeNode> children, ViewSettings settings)
{
	Unity3dRootModuleExtension rootModuleExtension = Unity3dModuleExtensionUtil.getRootModuleExtension(myProject);
	if(rootModuleExtension == null)
	{
		return children;
	}

	Boolean showMetaFiles = settings.getViewOption(Unity3dShowMetaFileProjectViewPaneOptionProvider.KEY);
	if(showMetaFiles == Boolean.TRUE)
	{
		return children;
	}

	List<AbstractTreeNode> nodes = new ArrayList<>(children.size());
	for(AbstractTreeNode child : children)
	{
		ProgressManager.checkCanceled();

		if(child instanceof ProjectViewNode)
		{
			VirtualFile virtualFile = ((ProjectViewNode) child).getVirtualFile();
			if(virtualFile != null && virtualFile.getFileType() == Unity3dMetaFileType.INSTANCE && haveOwnerFile(virtualFile))
			{
				continue;
			}
		}

		nodes.add(child);
	}
	return nodes;
}
 
Example 8
Source File: CompletionProgressIndicator.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void calculateItems(CompletionInitializationContext initContext, WeighingDelegate weigher, CompletionParameters parameters) {
  duringCompletion(initContext, parameters);
  ProgressManager.checkCanceled();

  CompletionService.getCompletionService().performCompletion(parameters, weigher);
  ProgressManager.checkCanceled();

  weigher.waitFor();
  ProgressManager.checkCanceled();
}
 
Example 9
Source File: BashFunctionVariantsProcessor.java    From BashSupport with Apache License 2.0 5 votes vote down vote up
public boolean execute(PsiElement element, ResolveState resolveState) {
    ProgressManager.checkCanceled();

    if (element instanceof BashFunctionDef) {
        final BashFunctionDef f = (BashFunctionDef) element;

        if (BashPsiUtils.isValidReferenceScope(startElement, element)) {
            functionDefs.add(f);
        }
    }

    return true;
}
 
Example 10
Source File: CompletionProgressIndicator.java    From consulo with Apache License 2.0 5 votes vote down vote up
void addItem(CompletionResult item) {
  if (!isRunning()) return;
  ProgressManager.checkCanceled();

  if (!myHandler.isTestingMode()) {
    LOG.assertTrue(!ApplicationManager.getApplication().isDispatchThread());
  }

  LookupElement lookupElement = item.getLookupElement();
  if (!myHasPsiElements && lookupElement.getPsiElement() != null) {
    myHasPsiElements = true;
  }

  boolean forceMiddleMatch = lookupElement.getUserData(CompletionLookupArrangerImpl.FORCE_MIDDLE_MATCH) != null;
  if (forceMiddleMatch) {
    myArranger.associateSorter(lookupElement, (CompletionSorterImpl)item.getSorter());
    addItemToLookup(item);
    return;
  }

  boolean allowMiddleMatches = myCount > CompletionLookupArrangerImpl.MAX_PREFERRED_COUNT * 2;
  if (allowMiddleMatches) {
    addDelayedMiddleMatches();
  }

  myArranger.associateSorter(lookupElement, (CompletionSorterImpl)item.getSorter());
  if (item.isStartMatch() || allowMiddleMatches) {
    addItemToLookup(item);
  }
  else {
    synchronized (myDelayedMiddleMatches) {
      myDelayedMiddleMatches.add(item);
    }
  }
}
 
Example 11
Source File: InspectionEngine.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
public static Map<LocalInspectionToolWrapper, Set<String>> getToolsToSpecifiedLanguages(@Nonnull List<LocalInspectionToolWrapper> toolWrappers) {
  Map<LocalInspectionToolWrapper, Set<String>> toolToLanguages = new THashMap<>();
  for (LocalInspectionToolWrapper wrapper : toolWrappers) {
    ProgressManager.checkCanceled();
    Set<String> specifiedLangIds = getDialectIdsSpecifiedForTool(wrapper);
    toolToLanguages.put(wrapper, specifiedLangIds);
  }
  return toolToLanguages;
}
 
Example 12
Source File: WorkspaceHelper.java    From intellij with Apache License 2.0 5 votes vote down vote up
private static WorkspacePath getPackagePath(
    BuildSystemProvider provider, WorkspaceRoot root, WorkspacePath workspacePath) {
  File file = root.fileForPath(workspacePath).getParentFile();
  while (file != null && FileUtil.isAncestor(root.directory(), file, false)) {
    ProgressManager.checkCanceled();
    if (provider.findBuildFileInDirectory(file) != null) {
      return root.workspacePathFor(file);
    }
    file = file.getParentFile();
  }
  return null;
}
 
Example 13
Source File: CSharpElementGroupImpl.java    From consulo-csharp with Apache License 2.0 5 votes vote down vote up
@Override
public boolean process(@Nonnull Processor<? super T> processor)
{
	for(T element : myElements)
	{
		ProgressManager.checkCanceled();

		if(!processor.process(element))
		{
			return false;
		}
	}
	return true;
}
 
Example 14
Source File: FileBasedIndexImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
<K> void ensureUpToDate(@Nonnull final ID<K, ?> indexId, @Nullable Project project, @Nullable GlobalSearchScope filter, @Nullable VirtualFile restrictedFile) {
  ProgressManager.checkCanceled();
  getChangedFilesCollector().ensureUpToDate();
  ApplicationManager.getApplication().assertReadAccessAllowed();

  NoAccessDuringPsiEvents.checkCallContext();

  if (!needsFileContentLoading(indexId)) {
    return; //indexed eagerly in foreground while building unindexed file list
  }
  if (filter == GlobalSearchScope.EMPTY_SCOPE) {
    return;
  }
  if (ActionUtil.isDumbMode(project)) {
    handleDumbMode(project);
  }

  if (myReentrancyGuard.get().booleanValue()) {
    //assert false : "ensureUpToDate() is not reentrant!";
    return;
  }
  myReentrancyGuard.set(Boolean.TRUE);

  try {
    if (isUpToDateCheckEnabled()) {
      try {
        if (!RebuildStatus.isOk(indexId)) {
          throw new ProcessCanceledException();
        }
        forceUpdate(project, filter, restrictedFile);
        indexUnsavedDocuments(indexId, project, filter, restrictedFile);
      }
      catch (RuntimeException e) {
        final Throwable cause = e.getCause();
        if (cause instanceof StorageException || cause instanceof IOException) {
          scheduleRebuild(indexId, e);
        }
        else {
          throw e;
        }
      }
    }
  }
  finally {
    myReentrancyGuard.set(Boolean.FALSE);
  }
}
 
Example 15
Source File: BashResolveUtil.java    From BashSupport with Apache License 2.0 4 votes vote down vote up
public static PsiElement resolve(BashVar bashVar, boolean dumbMode, ResolveProcessor processor) {
    if (bashVar == null || !bashVar.isPhysical()) {
        return null;
    }

    final String varName = bashVar.getReferenceName();
    if (varName == null) {
        return null;
    }

    PsiFile psiFile = BashPsiUtils.findFileContext(bashVar);
    VirtualFile virtualFile = psiFile.getVirtualFile();

    String filePath = virtualFile != null ? virtualFile.getPath() : null;
    Project project = bashVar.getProject();

    ResolveState resolveState = ResolveState.initial();

    GlobalSearchScope fileScope = GlobalSearchScope.fileScope(psiFile);

    Collection<BashVarDef> varDefs;
    if (dumbMode || isScratchFile(virtualFile) || isNotIndexedFile(project, virtualFile)) {
        varDefs = PsiTreeUtil.collectElementsOfType(psiFile, BashVarDef.class);
    } else {
        varDefs = StubIndex.getElements(BashVarDefIndex.KEY, varName, project, fileScope, BashVarDef.class);
    }

    for (BashVarDef varDef : varDefs) {
        ProgressManager.checkCanceled();

        processor.execute(varDef, resolveState);
    }

    if (!dumbMode && filePath != null) {
        Collection<BashIncludeCommand> includeCommands = StubIndex.getElements(BashIncludeCommandIndex.KEY, filePath, project, fileScope, BashIncludeCommand.class);
        if (!includeCommands.isEmpty()) {
            boolean varIsInFunction = BashPsiUtils.findNextVarDefFunctionDefScope(bashVar) != null;

            for (BashIncludeCommand command : includeCommands) {
                ProgressManager.checkCanceled();

                boolean includeIsInFunction = BashPsiUtils.findNextVarDefFunctionDefScope(command) != null;

                //either one of var or include command is in a function or the var is used after the include command
                if (varIsInFunction || includeIsInFunction || (BashPsiUtils.getFileTextOffset(bashVar) > BashPsiUtils.getFileTextEndOffset(command))) {
                    try {
                        resolveState = resolveState.put(Keys.resolvingIncludeCommand, command);

                        command.processDeclarations(processor, resolveState, command, bashVar);
                    } finally {
                        resolveState = resolveState.put(Keys.resolvingIncludeCommand, null);
                    }
                }
            }
        }
    }

    processor.prepareResults();

    return processor.getBestResult(false, bashVar);
}
 
Example 16
Source File: AbstractTreeHasher.java    From consulo with Apache License 2.0 4 votes vote down vote up
/**
 * Computes element hash using children hashes.
 * Creates only single PsiFragment.
 */
protected TreeHashResult computeElementHash(@Nonnull final PsiElement root, final PsiFragment upper, final NodeSpecificHasher hasher) {
  if (myForIndexing) {
    return TreeHashingUtils.computeElementHashForIndexing(this, myCallBack, root, upper, hasher);
  }
  ProgressManager.checkCanceled();
  final List<PsiElement> children = hasher.getNodeChildren(root);
  final int size = children.size();
  final int[] childHashes = new int[size];
  final int[] childCosts = new int[size];

  final PsiFragment fragment = buildFragment(hasher, root, getCost(root));

  if (upper != null) {
    fragment.setParent(upper);
  }

  if (size == 0 && !(root instanceof LeafElement)) {
    return new TreeHashResult(hasher.getNodeHash(root), hasher.getNodeCost(root), fragment);
  }

  for (int i = 0; i < size; i++) {
    final TreeHashResult res = hash(children.get(i), fragment, hasher);
    childHashes[i] = res.getHash();
    childCosts[i] = res.getCost();
  }

  final int c = hasher.getNodeCost(root) + vector(childCosts);
  final int h1 = hasher.getNodeHash(root);

  final int discardCost = getDiscardCost(root);

  for (int i = 0; i < size; i++) {
    if (childCosts[i] <= discardCost && ignoreChildHash(children.get(i))) {
      childHashes[i] = 0;
    }
  }
  final int h = h1 + vector(childHashes);

  if (myCallBack != null) {
    myCallBack.add(h, c, fragment);
  }

  return new TreeHashResult(h, c, fragment);
}
 
Example 17
Source File: DFAEngine.java    From consulo with Apache License 2.0 4 votes vote down vote up
public List<E> performDFA(final List<E> info) throws DFALimitExceededException {
    if (LOG.isDebugEnabled()) {
      LOG.debug("Performing DFA\n" + "Instance: " + myDfa + " Semilattice: " + mySemilattice + "\nCon");
    }

// initializing dfa
    final E initial = myDfa.initial();
    for (int i = 0; i < myFlow.length; i++) {
      info.add(i, initial);
    }

    final boolean[] visited = new boolean[myFlow.length];

    final boolean forward = myDfa.isForward();
    final int[] order = ControlFlowUtil.postOrder(myFlow);

// Count limit for number of iterations per worklist
    final int limit = getIterationLimit(forward);
    int dfaCount = 0;
    final long startTime = System.nanoTime();

    for (int i = forward ? 0 : myFlow.length - 1; forward ? i < myFlow.length : i >= 0; ) {
      // Check if canceled
      ProgressManager.checkCanceled();

      if (System.nanoTime() - startTime > TIME_LIMIT) {
        if (LOG.isDebugEnabled()) {
          LOG.debug("Time limit exceeded");
        }
        throw new DFALimitExceededException("Time limit exceeded");
      }

      // Iteration count per one worklist
      int count = 0;
      final Instruction instruction = myFlow[order[i]];
      final int number = instruction.num();

      if (!visited[number]) {
        final Queue<Instruction> worklist = new LinkedList<Instruction>();
        worklist.add(instruction);
        visited[number] = true;

        while (true) {
          // Check if canceled
          ProgressManager.checkCanceled();

          // It is essential to apply this check!!!
          // This gives us more chances that resulting info will be closer to expected result
          // Also it is used as indicator that "equals" method is implemented correctly in E
          count++;
          if (count > limit) {
            if (LOG.isDebugEnabled()) {
              LOG.debug("Iteration count exceeded on worklist");
            }
            throw new DFALimitExceededException("Iteration count exceeded on worklist");
          }

          final Instruction currentInstruction = worklist.poll();
          if (currentInstruction == null) {
            break;
          }

          final int currentNumber = currentInstruction.num();
          final E oldE = info.get(currentNumber);
          final E joinedE = join(currentInstruction, info);
          final E newE = myDfa.fun(joinedE, currentInstruction);
          if (!mySemilattice.eq(newE, oldE)) {
            if (LOG.isDebugEnabled()) {
              LOG.debug("Number: " + currentNumber + " old: " + oldE.toString() + " new: " + newE.toString());
            }
            info.set(currentNumber, newE);
            for (Instruction next : getNext(currentInstruction)) {
              worklist.add(next);
              visited[next.num()] = true;
            }
          }
        }
      }

      // Move to another worklist
      if (forward) {
        i++;
      }
      else {
        i--;
      }
      dfaCount += count;
    }
    if (LOG.isDebugEnabled()) {
      LOG.debug("Done in: " + (System.nanoTime() - startTime) / 10e6 + "ms. Ratio: " + dfaCount / myFlow.length);
    }
    return info;
  }
 
Example 18
Source File: TextFieldWithAutoCompletionContributor.java    From consulo with Apache License 2.0 4 votes vote down vote up
@RequiredReadAction
@Override
public void fillCompletionVariants(final CompletionParameters parameters, CompletionResultSet result) {
  PsiFile file = parameters.getOriginalFile();
  final TextFieldWithAutoCompletionListProvider<T> provider = file.getUserData(KEY);

  if (provider == null) {
    return;
  }
  String adv = provider.getAdvertisement();
  if (adv == null) {
    final String shortcut = getActionShortcut(IdeActions.ACTION_QUICK_JAVADOC);
    if (shortcut != null) {
      adv = provider.getQuickDocHotKeyAdvertisement(shortcut);
    }
  }
  if (adv != null) {
    result.addLookupAdvertisement(adv);
  }

  final String prefix = provider.getPrefix(parameters);
  if (prefix == null) {
    return;
  }
  if (parameters.getInvocationCount() == 0 && !file.getUserData(AUTO_POPUP_KEY)) {   // is autopopup
    return;
  }
  final PrefixMatcher prefixMatcher = provider.createPrefixMatcher(prefix);
  if (prefixMatcher != null) {
    result = result.withPrefixMatcher(prefixMatcher);
  }

  Collection<T> items = provider.getItems(prefix, true, parameters);
  addCompletionElements(result, provider, items, -10000);

  Future<Collection<T>>
    future =
    ApplicationManager.getApplication().executeOnPooledThread(new Callable<Collection<T>>() {
      @Override
      public Collection<T> call() {
        return provider.getItems(prefix, false, parameters);
      }
    });

  while (true) {
    try {
      Collection<T> tasks = future.get(100, TimeUnit.MILLISECONDS);
      if (tasks != null) {
        addCompletionElements(result, provider, tasks, 0);
        return;
      }
    }
    catch (ProcessCanceledException e) {
      throw e;
    }
    catch (Exception ignore) {

    }
    ProgressManager.checkCanceled();
  }
}
 
Example 19
Source File: MemberResolveScopeProcessor.java    From consulo-csharp with Apache License 2.0 4 votes vote down vote up
@RequiredReadAction
private Collection<PsiElement> applyTypeArguments(Collection<PsiElement> psiElements)
{
	if(!(myScopeElement instanceof CSharpReferenceExpression) || psiElements.size() == 0)
	{
		return psiElements;
	}

	int typeArgumentListSize = CSharpReferenceExpressionImplUtil.getTypeArgumentListSize(myScopeElement);
	if(typeArgumentListSize == 0)
	{
		return psiElements;
	}

	DotNetTypeRef[] typeArgumentListRefs = ((CSharpReferenceExpression) myScopeElement).getTypeArgumentListRefs();

	List<PsiElement> newPsiElements = new ArrayList<>(psiElements.size());
	for(PsiElement psiElement : psiElements)
	{
		ProgressManager.checkCanceled();

		PsiElement addItem = psiElement;

		if(psiElement instanceof CSharpElementGroup)
		{
			@SuppressWarnings("unchecked") CSharpElementGroup<PsiElement> elementGroup = (CSharpElementGroup<PsiElement>) psiElement;

			Collection<PsiElement> elements = elementGroup.getElements();

			boolean changed = false;
			final List<PsiElement> anotherItems = new ArrayList<>(elements.size());
			for(PsiElement temp : elements)
			{
				if(temp instanceof CSharpMethodDeclaration && ((CSharpMethodDeclaration) temp).getGenericParametersCount() == typeArgumentListSize)
				{
					DotNetGenericParameter[] genericParameters = ((CSharpMethodDeclaration) temp).getGenericParameters();

					DotNetGenericExtractor extractor = CSharpGenericExtractor.create(genericParameters, typeArgumentListRefs);

					anotherItems.add(GenericUnwrapTool.extract((CSharpMethodDeclaration) temp, extractor));
					changed = true;
				}
				else
				{
					anotherItems.add(temp);
				}
			}

			if(changed)
			{
				addItem = new CSharpElementGroupImpl<>(elementGroup.getProject(), elementGroup.getKey(), anotherItems);
			}
		}

		newPsiElements.add(addItem);
	}
	return newPsiElements;
}
 
Example 20
Source File: VcsDirtyScopeVfsListener.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nullable
@Override
public ChangeApplier prepareChange(@Nonnull List<? extends VFileEvent> events) {
  if (myForbid || !myVcsManager.hasAnyMappings()) return null;
  final FilesAndDirs dirtyFilesAndDirs = new FilesAndDirs();
  // collect files and directories - sources of events
  for (VFileEvent event : events) {
    ProgressManager.checkCanceled();

    final boolean isDirectory;
    if (event instanceof VFileCreateEvent) {
      if (!((VFileCreateEvent)event).getParent().isInLocalFileSystem()) {
        continue;
      }
      isDirectory = ((VFileCreateEvent)event).isDirectory();
    }
    else {
      final VirtualFile file = Objects.requireNonNull(event.getFile(), "All events but VFileCreateEvent have @NotNull getFile()");
      if (!file.isInLocalFileSystem()) {
        continue;
      }
      isDirectory = file.isDirectory();
    }

    if (event instanceof VFileMoveEvent) {
      add(myVcsManager, dirtyFilesAndDirs, VcsUtil.getFilePath(((VFileMoveEvent)event).getOldPath(), isDirectory));
      add(myVcsManager, dirtyFilesAndDirs, VcsUtil.getFilePath(((VFileMoveEvent)event).getNewPath(), isDirectory));
    }
    else if (event instanceof VFilePropertyChangeEvent && ((VFilePropertyChangeEvent)event).isRename()) {
      // if a file was renamed, then the file is dirty and its parent directory is dirty too;
      // if a directory was renamed, all its children are recursively dirty, the parent dir is also dirty but not recursively.
      FilePath oldPath = VcsUtil.getFilePath(((VFilePropertyChangeEvent)event).getOldPath(), isDirectory);
      FilePath newPath = VcsUtil.getFilePath(((VFilePropertyChangeEvent)event).getNewPath(), isDirectory);
      // the file is dirty recursively
      add(myVcsManager, dirtyFilesAndDirs, oldPath);
      add(myVcsManager, dirtyFilesAndDirs, newPath);
      FilePath parentPath = oldPath.getParentPath();
      if (parentPath != null) {
        addAsFiles(myVcsManager, dirtyFilesAndDirs, parentPath); // directory is dirty alone
      }
    }
    else {
      add(myVcsManager, dirtyFilesAndDirs, VcsUtil.getFilePath(event.getPath(), isDirectory));
    }
  }

  return new ChangeApplier() {
    @Override
    public void afterVfsChange() {
      markDirtyOnPooled(dirtyFilesAndDirs);
    }
  };
}