Search in sources :

Example 6 with CheckinEnvironment

use of com.intellij.openapi.vcs.checkin.CheckinEnvironment in project intellij-community by JetBrains.

the class NewFilesProcessor method addToVcsIfNeeded.

/**
   * @param localFileNames names of local files to add to VCS
   */
private static void addToVcsIfNeeded(@NotNull final Module module, @NotNull final String... localFileNames) {
    final LocalFileSystem fs = LocalFileSystem.getInstance();
    fs.refresh(false);
    final Project project = module.getProject();
    Arrays.stream(localFileNames).map(o -> fs.findFileByPath(o)).filter(o -> o != null).forEach(file -> {
        final AbstractVcs<?> vcs = VcsUtil.getVcsFor(project, file);
        if (vcs == null) {
            return;
        }
        final CheckinEnvironment environment = vcs.getCheckinEnvironment();
        if (environment != null) {
            environment.scheduleUnversionedFilesForAddition(Collections.singletonList(file));
        }
    });
}
Also used : VcsUtil(com.intellij.vcsUtil.VcsUtil) Arrays(java.util.Arrays) ModuleExtKt(com.jetbrains.extensions.ModuleExtKt) StringUtil(com.intellij.openapi.util.text.StringUtil) AbstractVcs(com.intellij.openapi.vcs.AbstractVcs) Project(com.intellij.openapi.project.Project) Module(com.intellij.openapi.module.Module) NotNull(org.jetbrains.annotations.NotNull) Collections(java.util.Collections) Sdk(com.intellij.openapi.projectRoots.Sdk) CheckinEnvironment(com.intellij.openapi.vcs.checkin.CheckinEnvironment) LocalFileSystem(com.intellij.openapi.vfs.LocalFileSystem) Project(com.intellij.openapi.project.Project) CheckinEnvironment(com.intellij.openapi.vcs.checkin.CheckinEnvironment) LocalFileSystem(com.intellij.openapi.vfs.LocalFileSystem)

Aggregations

CheckinEnvironment (com.intellij.openapi.vcs.checkin.CheckinEnvironment)6 Module (com.intellij.openapi.module.Module)1 Project (com.intellij.openapi.project.Project)1 Sdk (com.intellij.openapi.projectRoots.Sdk)1 StringUtil (com.intellij.openapi.util.text.StringUtil)1 AbstractVcs (com.intellij.openapi.vcs.AbstractVcs)1 VcsException (com.intellij.openapi.vcs.VcsException)1 LocalFileSystem (com.intellij.openapi.vfs.LocalFileSystem)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 MultiMap (com.intellij.util.containers.MultiMap)1 VcsUtil (com.intellij.vcsUtil.VcsUtil)1 ModuleExtKt (com.jetbrains.extensions.ModuleExtKt)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 NotNull (org.jetbrains.annotations.NotNull)1