com.intellij.psi.PsiFileSystemItem Java Examples

The following examples show how to use com.intellij.psi.PsiFileSystemItem. 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: DefaultFileNavigationContributor.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void processElementsWithName(@Nonnull String name, @Nonnull final Processor<NavigationItem> _processor, @Nonnull FindSymbolParameters parameters) {
  final boolean globalSearch = parameters.getSearchScope().isSearchInLibraries();
  final Processor<PsiFileSystemItem> processor = item -> {
    if (!globalSearch && ProjectCoreUtil.isProjectOrWorkspaceFile(item.getVirtualFile())) {
      return true;
    }
    return _processor.process(item);
  };

  boolean directoriesOnly = isDirectoryOnlyPattern(parameters);
  if (!directoriesOnly) {
    FilenameIndex.processFilesByName(name, false, processor, parameters.getSearchScope(), parameters.getProject(), parameters.getIdFilter());
  }

  if (directoriesOnly || Registry.is("ide.goto.file.include.directories")) {
    FilenameIndex.processFilesByName(name, true, processor, parameters.getSearchScope(), parameters.getProject(), parameters.getIdFilter());
  }
}
 
Example #2
Source File: FileTreeModelBuilder.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nullable
public PackageDependenciesNode findNode(PsiFileSystemItem file, final PsiElement psiElement) {
  if (file instanceof PsiDirectory) {
    return getModuleDirNode(file.getVirtualFile(), myFileIndex.getModuleForFile(file.getVirtualFile()), null);
  }
  PackageDependenciesNode parent = getFileParentNode(file.getVirtualFile());
  PackageDependenciesNode[] nodes = findNodeForPsiElement(parent, file);
  if (nodes == null || nodes.length == 0) {
    return null;
  }
  else {
    for (PackageDependenciesNode node : nodes) {
      if (node.getPsiElement() == psiElement) return node;
    }
    return nodes[0];
  }
}
 
Example #3
Source File: ExternalWorkspaceReferenceFragment.java    From intellij with Apache License 2.0 6 votes vote down vote up
@Nullable
private static BuildFile resolveProjectWorkspaceFile(Project project) {
  WorkspaceRoot projectRoot = WorkspaceRoot.fromProjectSafe(project);
  if (projectRoot == null) {
    return null;
  }
  for (String workspaceFileName :
      Blaze.getBuildSystemProvider(project).possibleWorkspaceFileNames()) {
    PsiFileSystemItem workspaceFile =
        BuildReferenceManager.getInstance(project)
            .resolveFile(projectRoot.fileForPath(new WorkspacePath(workspaceFileName)));
    if (workspaceFile != null) {
      return ObjectUtils.tryCast(workspaceFile, BuildFile.class);
    }
  }
  return null;
}
 
Example #4
Source File: FilePathCompletionContributor.java    From consulo with Apache License 2.0 6 votes vote down vote up
private static boolean fileMatchesPathPrefix(@Nullable final PsiFileSystemItem file, @Nonnull final List<String> pathPrefix) {
  if (file == null) return false;

  final List<String> contextParts = new ArrayList<>();
  PsiFileSystemItem parentFile = file;
  PsiFileSystemItem parent;
  while ((parent = parentFile.getParent()) != null) {
    if (parent.getName().length() > 0) contextParts.add(0, parent.getName().toLowerCase());
    parentFile = parent;
  }

  final String path = StringUtil.join(contextParts, "/");

  int nextIndex = 0;
  for (@NonNls final String s : pathPrefix) {
    if ((nextIndex = path.indexOf(s.toLowerCase(), nextIndex)) == -1) return false;
  }

  return true;
}
 
Example #5
Source File: FileSearchEverywhereContributor.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
@Override
public ListCellRenderer<Object> getElementsRenderer() {
  //noinspection unchecked
  return new SERenderer() {
    @Nonnull
    @Override
    protected ItemMatchers getItemMatchers(@Nonnull JList list, @Nonnull Object value) {
      ItemMatchers defaultMatchers = super.getItemMatchers(list, value);
      if (!(value instanceof PsiFileSystemItem) || myModelForRenderer == null) {
        return defaultMatchers;
      }

      return GotoFileModel.convertToFileItemMatchers(defaultMatchers, (PsiFileSystemItem)value, myModelForRenderer);
    }
  };
}
 
Example #6
Source File: FileIncludeManagerImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nullable
private PsiFileSystemItem doResolve(@Nonnull final FileIncludeInfo info, @Nonnull final PsiFile context) {
  if (info instanceof FileIncludeInfoImpl) {
    String id = ((FileIncludeInfoImpl)info).providerId;
    FileIncludeProvider provider = id == null ? null : myProviderMap.get(id);
    final PsiFileSystemItem resolvedByProvider = provider == null ? null : provider.resolveIncludedFile(info, context);
    if (resolvedByProvider != null) {
      return resolvedByProvider;
    }
  }

  PsiFileImpl psiFile = (PsiFileImpl)myPsiFileFactory.createFileFromText("dummy.txt", PlainTextFileType.INSTANCE, info.path);
  psiFile.setOriginalFile(context);
  return new FileReferenceSet(psiFile) {
    @Override
    protected boolean useIncludingFileAsContext() {
      return false;
    }
  }.resolve();
}
 
Example #7
Source File: NewElementToolbarAction.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void actionPerformed(AnActionEvent e) {
  if (e.getData(LangDataKeys.IDE_VIEW) == null) {
    final Project project = e.getData(CommonDataKeys.PROJECT);
    final PsiFileSystemItem psiFile = e.getData(LangDataKeys.PSI_FILE).getParent();
    ProjectView.getInstance(project).selectCB(psiFile, psiFile.getVirtualFile(), true).doWhenDone(new Runnable() {
      @Override
      public void run() {
        showPopup(DataManager.getInstance().getDataContext());
      }
    });
  }
  else {
    super.actionPerformed(e);
  }
}
 
Example #8
Source File: VirtualFileTestContextProvider.java    From intellij with Apache License 2.0 6 votes vote down vote up
@Nullable
@Override
public RunConfigurationContext getTestContext(ConfigurationContext context) {
  PsiElement psi = context.getPsiLocation();
  if (!(psi instanceof PsiFileSystemItem) || !(psi instanceof FakePsiElement)) {
    return null;
  }
  VirtualFile vf = ((PsiFileSystemItem) psi).getVirtualFile();
  if (vf == null) {
    return null;
  }
  WorkspacePath path = getWorkspacePath(context.getProject(), vf);
  if (path == null) {
    return null;
  }
  return CachedValuesManager.getCachedValue(
      psi,
      () ->
          CachedValueProvider.Result.create(
              doFindTestContext(context, vf, psi, path),
              PsiModificationTracker.MODIFICATION_COUNT,
              BlazeSyncModificationTracker.getInstance(context.getProject())));
}
 
Example #9
Source File: ProjectViewLabelReference.java    From intellij with Apache License 2.0 6 votes vote down vote up
@Nullable
private PsiFileSystemItem resolveFile(String path) {
  if (path.startsWith("/") || path.contains(":")) {
    return null;
  }
  BuildReferenceManager manager = BuildReferenceManager.getInstance(getProject());
  path = StringUtil.trimStart(path, "-");
  File file = manager.resolvePackage(WorkspacePath.createIfValid(path));
  if (file == null) {
    return null;
  }
  VirtualFile vf =
      VirtualFileSystemProvider.getInstance().getSystem().findFileByPath(file.getPath());
  if (vf == null) {
    return null;
  }
  PsiManager psiManager = PsiManager.getInstance(getProject());
  return vf.isDirectory() ? psiManager.findDirectory(vf) : psiManager.findFile(vf);
}
 
Example #10
Source File: BlazeCoverageAnnotator.java    From intellij with Apache License 2.0 6 votes vote down vote up
private boolean showCoverage(PsiFileSystemItem psiFile) {
  if (coverageFilePaths.isEmpty()) {
    return false;
  }
  VirtualFile vf = psiFile.getVirtualFile();
  if (vf == null) {
    return false;
  }
  String filePath = normalizeFilePath(vf.getPath());
  for (String path : coverageFilePaths) {
    if (filePath.startsWith(path)) {
      return true;
    }
  }
  return false;
}
 
Example #11
Source File: ResolvingTest.java    From idea-gitignore with MIT License 6 votes vote down vote up
private void doTest(@NotNull String beforeText, String... expectedResolve) {
    myFixture.configureByText(GitFileType.INSTANCE, beforeText);
    PsiPolyVariantReference reference = ((PsiPolyVariantReference) myFixture.getReferenceAtCaretPosition());
    assertNotNull(reference);

    final VirtualFile rootFile = myFixture.getFile().getContainingDirectory().getVirtualFile();
    ResolveResult[] resolveResults = reference.multiResolve(true);
    List<String> actualResolve = ContainerUtil.map(resolveResults, new Function<ResolveResult, String>() {
        @Override
        public String fun(ResolveResult resolveResult) {
            PsiElement resolveResultElement = resolveResult.getElement();
            assertNotNull(resolveResultElement);
            assertInstanceOf(resolveResultElement, PsiFileSystemItem.class);
            PsiFileSystemItem fileSystemItem = (PsiFileSystemItem) resolveResultElement;
            return VfsUtilCore.getRelativePath(fileSystemItem.getVirtualFile(), rootFile, '/');
        }
    });

    assertContainsElements(actualResolve, expectedResolve);
}
 
Example #12
Source File: ProjectViewNode.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public Collection<VirtualFile> getRoots() {
  Value value = getValue();

  if (value instanceof RootsProvider) {
    return ((RootsProvider)value).getRoots();
  }
  else if (value instanceof PsiFile) {
    PsiFile vFile = ((PsiFile)value).getContainingFile();
    if (vFile != null && vFile.getVirtualFile() != null) {
      return Collections.singleton(vFile.getVirtualFile());
    }
  }
  else if (value instanceof VirtualFile) {
    return Collections.singleton(((VirtualFile)value));
  }
  else if (value instanceof PsiFileSystemItem) {
    return Collections.singleton(((PsiFileSystemItem)value).getVirtualFile());
  }

  return Collections.emptyList();
}
 
Example #13
Source File: GotoFileItemProvider.java    From consulo with Apache License 2.0 6 votes vote down vote up
private Iterable<FoundItemDescriptor<PsiFileSystemItem>> matchQualifiers(MinusculeMatcher qualifierMatcher, Iterable<? extends PsiFileSystemItem> iterable) {
  List<FoundItemDescriptor<PsiFileSystemItem>> matching = new ArrayList<>();
  for (PsiFileSystemItem item : iterable) {
    ProgressManager.checkCanceled();
    String qualifier = Objects.requireNonNull(getParentPath(item));
    FList<TextRange> fragments = qualifierMatcher.matchingFragments(qualifier);
    if (fragments != null) {
      int gapPenalty = fragments.isEmpty() ? 0 : qualifier.length() - fragments.get(fragments.size() - 1).getEndOffset();
      int degree = qualifierMatcher.matchingDegree(qualifier, false, fragments) - gapPenalty;
      matching.add(new FoundItemDescriptor<>(item, degree));
    }
  }
  if (matching.size() > 1) {
    Comparator<FoundItemDescriptor<PsiFileSystemItem>> comparator = Comparator.comparing((FoundItemDescriptor<PsiFileSystemItem> res) -> res.getWeight()).reversed();
    Collections.sort(matching, comparator);
  }
  return matching;
}
 
Example #14
Source File: BlazePyBuiltinReferenceResolveProvider.java    From intellij with Apache License 2.0 6 votes vote down vote up
@Nullable
private static PyBuiltinCache getBuiltInCache(PyQualifiedExpression element) {
  final PsiElement realContext = PyPsiUtils.getRealContext(element);
  PsiFileSystemItem psiFile = realContext.getContainingFile();
  if (psiFile == null) {
    return null;
  }
  Sdk sdk = PyBuiltinCache.findSdkForFile(psiFile);
  if (sdk != null && sdk.getSdkType() instanceof PythonSdkType) {
    // this case is already handled by PythonBuiltinReferenceResolveProvider
    return null;
  }
  Sdk pythonSdk = PySdkUtils.getPythonSdk(psiFile.getProject());
  return pythonSdk != null
      ? PythonSdkPathCache.getInstance(psiFile.getProject(), pythonSdk).getBuiltins()
      : null;
}
 
Example #15
Source File: PsiFileSystemItemUtil.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nullable
public static String getRelativePath(PsiFileSystemItem src, PsiFileSystemItem dst) {
  final PsiFileSystemItem commonAncestor = getCommonAncestor(src, dst);

  if (commonAncestor != null) {
    StringBuilder buffer = new StringBuilder();
    if (!src.equals(commonAncestor)) {
      while (!commonAncestor.equals(src.getParent())) {
        buffer.append("..").append('/');
        src = src.getParent();
        assert src != null;
      }
    }
    buffer.append(getRelativePathFromAncestor(dst, commonAncestor));
    return buffer.toString();
  }

  return null;
}
 
Example #16
Source File: FileIncludeManagerImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void processIncludingFiles(PsiFile context, Processor<? super Pair<VirtualFile, FileIncludeInfo>> processor) {
  context = context.getOriginalFile();
  VirtualFile contextFile = context.getVirtualFile();
  if (contextFile == null) return;

  String originalName = context.getName();
  Collection<String> names = getPossibleIncludeNames(context, originalName);

  GlobalSearchScope scope = GlobalSearchScope.allScope(myProject);
  for (String name : names) {
    MultiMap<VirtualFile, FileIncludeInfoImpl> infoList = FileIncludeIndex.getIncludingFileCandidates(name, scope);
    for (VirtualFile candidate : infoList.keySet()) {
      PsiFile psiFile = myPsiManager.findFile(candidate);
      if (psiFile == null || context.equals(psiFile)) continue;
      for (FileIncludeInfo info : infoList.get(candidate)) {
        PsiFileSystemItem item = resolveFileInclude(info, psiFile);
        if (item != null && contextFile.equals(item.getVirtualFile())) {
          if (!processor.process(Pair.create(candidate, info))) {
            return;
          }
        }
      }
    }
  }
}
 
Example #17
Source File: SearchRequestCollector.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void searchWord(@Nonnull String word, @Nonnull SearchScope searchScope, boolean caseSensitive, @Nonnull PsiElement searchTarget) {
  final short searchContext = (short)(UsageSearchContext.IN_CODE |
                                      UsageSearchContext.IN_FOREIGN_LANGUAGES |
                                      UsageSearchContext.IN_COMMENTS |
                                      (searchTarget instanceof PsiFileSystemItem ? UsageSearchContext.IN_STRINGS : 0));
  searchWord(word, searchScope, searchContext, caseSensitive, searchTarget);
}
 
Example #18
Source File: PsiFileSystemItemUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
static PsiFileSystemItem getCommonAncestor(PsiFileSystemItem file1, PsiFileSystemItem file2) {
  PsiFileSystemItem[] path1 = getPathComponents(file1);
  PsiFileSystemItem[] path2 = getPathComponents(file2);

  PsiFileSystemItem[] minLengthPath;
  PsiFileSystemItem[] maxLengthPath;
  if (path1.length < path2.length) {
    minLengthPath = path1;
    maxLengthPath = path2;
  }
  else {
    minLengthPath = path2;
    maxLengthPath = path1;
  }

  int lastEqualIdx = -1;
  for (int i = 0; i < minLengthPath.length; i++) {
    if (minLengthPath[i].equals(maxLengthPath[i])) {
      lastEqualIdx = i;
    }
    else {
      break;
    }
  }
  return lastEqualIdx != -1 ? minLengthPath[lastEqualIdx] : null;
}
 
Example #19
Source File: FilenameIndex.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static boolean processFilesByName(@Nonnull final String name,
                                         boolean directories,
                                         boolean caseSensitively,
                                         @Nonnull Processor<? super PsiFileSystemItem> processor,
                                         @Nonnull final GlobalSearchScope scope,
                                         @Nonnull final Project project,
                                         @Nullable IdFilter idFilter) {
  final Collection<VirtualFile> files;

  if (caseSensitively) {
    files = getService().getVirtualFilesByName(project, name, scope, idFilter);
  }
  else {
    files = getVirtualFilesByNameIgnoringCase(name, scope, project, idFilter);
  }

  if (files.isEmpty()) return false;
  PsiManager psiManager = PsiManager.getInstance(project);
  int processedFiles = 0;

  for (VirtualFile file : files) {
    if (!file.isValid()) continue;
    if (!directories && !file.isDirectory()) {
      PsiFile psiFile = psiManager.findFile(file);
      if (psiFile != null) {
        if (!processor.process(psiFile)) return true;
        ++processedFiles;
      }
    }
    else if (directories && file.isDirectory()) {
      PsiDirectory dir = psiManager.findDirectory(file);
      if (dir != null) {
        if (!processor.process(dir)) return true;
        ++processedFiles;
      }
    }
  }
  return processedFiles > 0;
}
 
Example #20
Source File: FilenameIndex.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
public static PsiFileSystemItem[] getFilesByName(@Nonnull Project project, @Nonnull String name, @Nonnull final GlobalSearchScope scope, boolean directories) {
  SmartList<PsiFileSystemItem> result = new SmartList<>();
  Processor<PsiFileSystemItem> processor = Processors.cancelableCollectProcessor(result);
  processFilesByName(name, directories, processor, scope, project, null);

  if (directories) {
    return result.toArray(new PsiFileSystemItem[0]);
  }
  //noinspection SuspiciousToArrayCall
  return result.toArray(PsiFile.EMPTY_ARRAY);
}
 
Example #21
Source File: HaxeSourceRootModel.java    From intellij-haxe with Apache License 2.0 5 votes vote down vote up
@Nullable
public String resolvePath(PsiFileSystemItem fileSystemItem) {
  String rootPath = root.getPath();
  String itemPath = fileSystemItem.getVirtualFile().getPath();
  if (itemPath.equals(rootPath)) {
    return "";
  }

  if (itemPath.startsWith(rootPath)) {
    return itemPath.substring(rootPath.length() + 1);
  }

  return null;
}
 
Example #22
Source File: NullFileReferenceHelper.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
@Nonnull
public Collection<PsiFileSystemItem> getContexts(final Project project, @Nonnull final VirtualFile file) {
  final PsiFileSystemItem item = getPsiFileSystemItem(project, file);
  if (item != null) {
    final PsiFileSystemItem parent = item.getParent();
    if (parent != null) {
      return Collections.singleton(parent);
    }
  }
  return Collections.emptyList();
}
 
Example #23
Source File: PsiFileSystemItemUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
static PsiFileSystemItem[] getPathComponents(PsiFileSystemItem file) {
  LinkedList<PsiFileSystemItem> componentsList = new LinkedList<PsiFileSystemItem>();
  while (file != null) {
    componentsList.addFirst(file);
    file = file.getParent();
  }
  return componentsList.toArray(new PsiFileSystemItem[componentsList.size()]);
}
 
Example #24
Source File: GotoFileCellRenderer.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
protected String getContainerText(PsiFileSystemItem element, String name) {
  PsiFileSystemItem parent = element.getParent();
  final PsiDirectory psiDirectory = parent instanceof PsiDirectory ? (PsiDirectory)parent : null;
  if (psiDirectory == null) return null;
  final VirtualFile virtualFile = psiDirectory.getVirtualFile();
  final String relativePath = getRelativePath(virtualFile, element.getProject());
  if (relativePath == null) return "( " + File.separator + " )";
  String path = FilePathSplittingPolicy.SPLIT_BY_SEPARATOR.getOptimalTextForComponent(name + "          ", new File(relativePath), this, myMaxWidth);
  return "(" + path + ")";
}
 
Example #25
Source File: DefaultFindUsagesHandlerFactory.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public boolean canFindUsages(@Nonnull final PsiElement element) {
  if (element instanceof PsiFileSystemItem) {
    if (((PsiFileSystemItem)element).getVirtualFile() == null) return false;
  }
  else if (!LanguageFindUsages.INSTANCE.forLanguage(element.getLanguage()).canFindUsagesFor(element)) {
    return false;
  }
  return element.isValid();
}
 
Example #26
Source File: ImagePreviewComponent.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static JComponent getPreviewComponent(@Nullable final PsiElement parent) {
  if (parent == null) {
    return null;
  }
  final PsiReference[] references = parent.getReferences();
  for (final PsiReference reference : references) {
    final PsiElement fileItem = reference.resolve();
    if (fileItem instanceof PsiFileSystemItem) {
      final PsiFileSystemItem item = (PsiFileSystemItem)fileItem;
      if (!item.isDirectory()) {
        final VirtualFile file = item.getVirtualFile();
        if (file != null && supportedExtensions.contains(file.getExtension())) {
          try {
            refresh(file);
            SoftReference<BufferedImage> imageRef = file.getUserData(BUFFERED_IMAGE_REF_KEY);
            final BufferedImage image = SoftReference.dereference(imageRef);
            if (image != null) {
              return new ImagePreviewComponent(image, file.getLength());
            }
          }
          catch (IOException ignored) {
            // nothing
          }
        }
      }
    }
  }

  return null;
}
 
Example #27
Source File: BlazeGoImportResolver.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Nullable
static PsiFileSystemItem getInstance(PsiElement element) {
  if (element instanceof PsiFileSystemItem) {
    return (PsiFileSystemItem) element;
  } else if (element instanceof FuncallExpression) {
    String name = ((FuncallExpression) element).getName();
    if (name != null) {
      return new GoPackageFileSystemItem(name, (FuncallExpression) element);
    }
  }
  return null;
}
 
Example #28
Source File: HaxeSourceRootModel.java    From intellij-haxe with Apache License 2.0 5 votes vote down vote up
public boolean contains(PsiFileSystemItem file) {
  if (this == DUMMY) return false;

  VirtualFile virtualFile = file.getVirtualFile();
  if (virtualFile == null) {
    virtualFile = file.getOriginalElement().getContainingFile().getVirtualFile();
  }
  if (virtualFile == null) {
    virtualFile = file.getUserData(IndexingDataKeys.VIRTUAL_FILE);
  }

  return virtualFile != null && (virtualFile.getCanonicalPath() + '/').startsWith(root.getCanonicalPath() + '/');
}
 
Example #29
Source File: BlazeGoImportResolver.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
public PsiFileSystemItem getParent() {
  return Optional.of(rule)
      .map(FuncallExpression::getContainingFile)
      .map(BuildFile::getParent)
      .orElse(null);
}
 
Example #30
Source File: PsiExtraFileReference.java    From netbeans-mmd-plugin with Apache License 2.0 5 votes vote down vote up
public void retargetToFile(final PsiFileSystemItem file) {
  final MMapURI oldUri = extraFile.getMMapURI();
  try {
    final MMapURI newUri = RefactoringUtils.makeNewMMapUri(extraFile.getProject(), oldUri, file.getVirtualFile());
    final String packedNewMindMap = RefactoringUtils.replaceMMUriToNewFile(extraFile, oldUri, newUri);
    final PsiFile containingFile = extraFile.getContainingFile();

    final Document document = FileDocumentManager.getInstance().getDocument(containingFile.getVirtualFile());

    CommandProcessor.getInstance().executeCommand(containingFile.getProject(), new Runnable() {
      @Override
      public void run() {
        ApplicationManager.getApplication().runWriteAction(new Runnable() {
          @Override
          public void run() {
            final String packedMindMap = packedNewMindMap;
            document.setText(packedMindMap);
            FileDocumentManager.getInstance().saveDocument(document);
          }
        });
      }
    }, null, null, document);

    extraFile.setMMapURI(newUri);

  } catch (IOException ex) {
    throw new IncorrectOperationException("Can't update links in mind map", (Throwable) ex);
  }
}