Java Code Examples for com.intellij.openapi.roots.ContentEntry#getFile()

The following examples show how to use com.intellij.openapi.roots.ContentEntry#getFile() . 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: VueModuleBuilder.java    From vue-for-idea with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void setupRootModel(ModifiableRootModel modifiableRootModel) throws ConfigurationException {
    ContentEntry contentEntry = doAddContentEntry(modifiableRootModel);
    final VirtualFile baseDir = contentEntry == null ? null : contentEntry.getFile();
    if (baseDir != null) {
        setupProject(modifiableRootModel, baseDir, myWizardData);
    }
}
 
Example 2
Source File: ContentRootDataService.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
private static ContentEntry findOrCreateContentRoot(@Nonnull ModifiableRootModel model, @Nonnull String path) {
  ContentEntry[] entries = model.getContentEntries();

  for (ContentEntry entry : entries) {
    VirtualFile file = entry.getFile();
    if (file == null) {
      continue;
    }
    if (ExternalSystemApiUtil.getLocalFileSystemPath(file).equals(path)) {
      return entry;
    }
  }
  return model.addContentEntry(toVfsUrl(path));
}
 
Example 3
Source File: ContentEntriesEditor.java    From consulo with Apache License 2.0 4 votes vote down vote up
private void validateContentEntriesCandidates(VirtualFile[] files) throws Exception {
  for (final VirtualFile file : files) {
    // check for collisions with already existing entries
    for (final ContentEntry contentEntry : myEntryToEditorMap.keySet()) {
      final VirtualFile contentEntryFile = contentEntry.getFile();
      if (contentEntryFile == null) {
        continue;  // skip invalid entry
      }
      if (contentEntryFile.equals(file)) {
        throw new Exception(ProjectBundle.message("module.paths.add.content.already.exists.error", file.getPresentableUrl()));
      }
      if (VfsUtilCore.isAncestor(contentEntryFile, file, true)) {
        // intersection not allowed
        throw new Exception(
          ProjectBundle.message("module.paths.add.content.intersect.error", file.getPresentableUrl(),
                                contentEntryFile.getPresentableUrl()));
      }
      if (VfsUtilCore.isAncestor(file, contentEntryFile, true)) {
        // intersection not allowed
        throw new Exception(
          ProjectBundle.message("module.paths.add.content.dominate.error", file.getPresentableUrl(),
                                contentEntryFile.getPresentableUrl()));
      }
    }
    // check if the same root is configured for another module
    final Module[] modules = myModulesProvider.getModules();
    for (final Module module : modules) {
      if (myModuleName.equals(module.getName())) {
        continue;
      }
      ModuleRootModel rootModel = myModulesProvider.getRootModel(module);
      LOG.assertTrue(rootModel != null);
      final VirtualFile[] moduleContentRoots = rootModel.getContentRoots();
      for (VirtualFile moduleContentRoot : moduleContentRoots) {
        if (file.equals(moduleContentRoot)) {
          throw new Exception(
            ProjectBundle.message("module.paths.add.content.duplicate.error", file.getPresentableUrl(), module.getName()));
        }
      }
    }
  }
}