Search in sources :

Example 81 with Nullable

use of org.jetbrains.annotations.Nullable in project intellij-community by JetBrains.

the class MavenProjectImporter method importProject.

@Nullable
public List<MavenProjectsProcessorTask> importProject() {
    List<MavenProjectsProcessorTask> postTasks = new ArrayList<>();
    boolean hasChanges;
    // in the case projects are changed during importing we must memorise them
    myAllProjects = new LinkedHashSet<>(myProjectsTree.getProjects());
    // some projects may already have been removed from the tree
    myAllProjects.addAll(myProjectsToImportWithChanges.keySet());
    hasChanges = deleteIncompatibleModules();
    myProjectsToImportWithChanges = collectProjectsToImport(myProjectsToImportWithChanges);
    mapMavenProjectsToModulesAndNames();
    if (myProject.isDisposed())
        return null;
    final boolean projectsHaveChanges = projectsToImportHaveChanges();
    if (projectsHaveChanges) {
        hasChanges = true;
        importModules(postTasks);
        scheduleRefreshResolvedArtifacts(postTasks);
    }
    if (projectsHaveChanges || myImportModuleGroupsRequired) {
        hasChanges = true;
        configModuleGroups();
    }
    if (myProject.isDisposed())
        return null;
    try {
        boolean modulesDeleted = deleteObsoleteModules();
        hasChanges |= modulesDeleted;
        if (hasChanges) {
            removeUnusedProjectLibraries();
        }
    } catch (ProcessCanceledException e) {
        throw e;
    } catch (Exception e) {
        disposeModifiableModels();
        LOG.error(e);
        return null;
    }
    if (hasChanges) {
        MavenUtil.invokeAndWaitWriteAction(myProject, () -> {
            myModelsProvider.commit();
            if (projectsHaveChanges) {
                removeOutdatedCompilerConfigSettings();
                for (MavenProject mavenProject : myAllProjects) {
                    Module module = myMavenProjectToModule.get(mavenProject);
                    if (module != null && module.isDisposed()) {
                        module = null;
                    }
                    for (MavenModuleConfigurer configurer : MavenModuleConfigurer.getConfigurers()) {
                        configurer.configure(mavenProject, myProject, module);
                    }
                }
            }
        });
    } else {
        disposeModifiableModels();
    }
    return postTasks;
}
Also used : Module(com.intellij.openapi.module.Module) ProcessCanceledException(com.intellij.openapi.progress.ProcessCanceledException) MavenProcessCanceledException(org.jetbrains.idea.maven.utils.MavenProcessCanceledException) IOException(java.io.IOException) MavenModuleConfigurer(org.jetbrains.idea.maven.importing.configurers.MavenModuleConfigurer) ProcessCanceledException(com.intellij.openapi.progress.ProcessCanceledException) MavenProcessCanceledException(org.jetbrains.idea.maven.utils.MavenProcessCanceledException) Nullable(org.jetbrains.annotations.Nullable)

Example 82 with Nullable

use of org.jetbrains.annotations.Nullable in project intellij-community by JetBrains.

the class MavenNavigationUtil method createNavigatableForDependency.

@Nullable
public static Navigatable createNavigatableForDependency(final Project project, final VirtualFile file, final MavenArtifact artifact) {
    return new NavigatableAdapter() {

        public void navigate(boolean requestFocus) {
            if (!file.isValid())
                return;
            MavenDomProjectModel projectModel = MavenDomUtil.getMavenDomProjectModel(project, file);
            if (projectModel == null)
                return;
            MavenDomDependency dependency = findDependency(projectModel, artifact.getGroupId(), artifact.getArtifactId());
            if (dependency == null)
                return;
            XmlTag artifactId = dependency.getArtifactId().getXmlTag();
            if (artifactId == null)
                return;
            navigate(project, artifactId.getContainingFile().getVirtualFile(), artifactId.getTextOffset() + artifactId.getName().length() + 2, requestFocus);
        }
    };
}
Also used : MavenDomProjectModel(org.jetbrains.idea.maven.dom.model.MavenDomProjectModel) NavigatableAdapter(com.intellij.pom.NavigatableAdapter) MavenDomDependency(org.jetbrains.idea.maven.dom.model.MavenDomDependency) XmlTag(com.intellij.psi.xml.XmlTag) Nullable(org.jetbrains.annotations.Nullable)

Example 83 with Nullable

use of org.jetbrains.annotations.Nullable in project intellij-community by JetBrains.

the class SvnCheckinHandlerFactory method createVcsHandler.

@NotNull
@Override
protected CheckinHandler createVcsHandler(final CheckinProjectPanel panel) {
    final Project project = panel.getProject();
    final Collection<VirtualFile> commitRoots = panel.getRoots();
    return new CheckinHandler() {

        private Collection<Change> myChanges = panel.getSelectedChanges();

        @Override
        public RefreshableOnComponent getBeforeCheckinConfigurationPanel() {
            return null;
        }

        @Override
        public ReturnResult beforeCheckin(@Nullable CommitExecutor executor, PairConsumer<Object, Object> additionalDataConsumer) {
            if (executor instanceof LocalCommitExecutor)
                return ReturnResult.COMMIT;
            final SvnVcs vcs = SvnVcs.getInstance(project);
            final MultiMap<String, WorkingCopyFormat> copiesInfo = splitIntoCopies(vcs, myChanges);
            final List<String> repoUrls = new ArrayList<>();
            for (Map.Entry<String, Collection<WorkingCopyFormat>> entry : copiesInfo.entrySet()) {
                if (entry.getValue().size() > 1) {
                    repoUrls.add(entry.getKey());
                }
            }
            if (!repoUrls.isEmpty()) {
                final String join = StringUtil.join(repoUrls, ",\n");
                final int isOk = Messages.showOkCancelDialog(project, SvnBundle.message("checkin.different.formats.involved", repoUrls.size() > 1 ? 1 : 0, join), "Subversion: Commit Will Split", Messages.getWarningIcon());
                return Messages.OK == isOk ? ReturnResult.COMMIT : ReturnResult.CANCEL;
            }
            return ReturnResult.COMMIT;
        }

        @Override
        public void includedChangesChanged() {
            myChanges = panel.getSelectedChanges();
        }

        @Override
        public void checkinSuccessful() {
            if (SvnConfiguration.getInstance(project).isAutoUpdateAfterCommit()) {
                final VirtualFile[] roots = ProjectLevelVcsManager.getInstance(project).getRootsUnderVcs(SvnVcs.getInstance(project));
                final List<FilePath> paths = new ArrayList<>();
                for (VirtualFile root : roots) {
                    boolean take = false;
                    for (VirtualFile commitRoot : commitRoots) {
                        if (VfsUtilCore.isAncestor(root, commitRoot, false)) {
                            take = true;
                            break;
                        }
                    }
                    if (take) {
                        paths.add(VcsUtil.getFilePath(root));
                    }
                }
                if (paths.isEmpty())
                    return;
                ApplicationManager.getApplication().invokeLater(() -> AutoSvnUpdater.run(new AutoSvnUpdater(project, paths.toArray(new FilePath[paths.size()])), ActionInfo.UPDATE.getActionName()), ModalityState.NON_MODAL);
            }
        }
    };
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FilePath(com.intellij.openapi.vcs.FilePath) LocalCommitExecutor(com.intellij.openapi.vcs.changes.LocalCommitExecutor) ArrayList(java.util.ArrayList) CheckinHandler(com.intellij.openapi.vcs.checkin.CheckinHandler) LocalCommitExecutor(com.intellij.openapi.vcs.changes.LocalCommitExecutor) CommitExecutor(com.intellij.openapi.vcs.changes.CommitExecutor) Project(com.intellij.openapi.project.Project) PairConsumer(com.intellij.util.PairConsumer) Collection(java.util.Collection) AutoSvnUpdater(org.jetbrains.idea.svn.update.AutoSvnUpdater) Map(java.util.Map) MultiMap(com.intellij.util.containers.MultiMap) Nullable(org.jetbrains.annotations.Nullable) NotNull(org.jetbrains.annotations.NotNull)

Example 84 with Nullable

use of org.jetbrains.annotations.Nullable in project intellij-community by JetBrains.

the class SvnAnnotationProvider method restore.

@Nullable
@Override
public FileAnnotation restore(@NotNull VcsAnnotation vcsAnnotation, @NotNull VcsAbstractHistorySession session, @NotNull String annotatedContent, boolean forCurrentRevision, VcsRevisionNumber revisionNumber) {
    final SvnFileAnnotation annotation = new SvnFileAnnotation(myVcs, vcsAnnotation.getFilePath().getVirtualFile(), annotatedContent, revisionNumber);
    final VcsLineAnnotationData basicAnnotation = vcsAnnotation.getBasicAnnotation();
    final VcsLineAnnotationData data = vcsAnnotation.getAdditionalAnnotations().get(MERGED_KEY);
    final Map<VcsRevisionNumber, VcsFileRevision> historyAsMap = session.getHistoryAsMap();
    final Map<VcsRevisionNumber, VcsFileRevision> cachedOtherRevisions = vcsAnnotation.getCachedOtherRevisions();
    for (int i = 0; i < basicAnnotation.getNumLines(); i++) {
        final VcsRevisionNumber revision = basicAnnotation.getRevision(i);
        final VcsRevisionNumber mergedData = data == null ? null : data.getRevision(i);
        final SvnFileRevision fileRevision = (SvnFileRevision) historyAsMap.get(revision);
        if (fileRevision == null)
            return null;
        if (mergedData == null) {
            annotation.setLineInfo(i, fileRevision.getCommitInfo(), null);
        } else {
            final SvnFileRevision mergedRevision = (SvnFileRevision) cachedOtherRevisions.get(mergedData);
            if (mergedRevision == null)
                return null;
            annotation.setLineInfo(i, fileRevision.getCommitInfo(), mergedRevision.getCommitInfo());
        }
    }
    if (vcsAnnotation.getFirstRevision() != null) {
        annotation.setFirstRevision(((SvnRevisionNumber) vcsAnnotation.getFirstRevision()).getRevision());
    }
    for (VcsFileRevision revision : session.getRevisionList()) {
        annotation.setRevision(((SvnRevisionNumber) revision.getRevisionNumber()).getRevision().getNumber(), (SvnFileRevision) revision);
    }
    return annotation;
}
Also used : SvnFileRevision(org.jetbrains.idea.svn.history.SvnFileRevision) Nullable(org.jetbrains.annotations.Nullable)

Example 85 with Nullable

use of org.jetbrains.annotations.Nullable in project intellij-community by JetBrains.

the class InfoCommandRepositoryProvider method get.

@Nullable
@Override
public Repository get() {
    Repository result;
    if (myTarget.isURL()) {
        // TODO: Also could still execute info when target is url - either to use info for authentication or to just get correct repository
        // TODO: url in case of "read" operations are allowed anonymously.
        result = new Repository(myTarget.getURL());
    } else {
        Info info = myVcs.getInfo(myTarget.getFile());
        result = info != null ? new Repository(info.getRepositoryRootURL()) : null;
    }
    return result;
}
Also used : Info(org.jetbrains.idea.svn.info.Info) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

Nullable (org.jetbrains.annotations.Nullable)4694 VirtualFile (com.intellij.openapi.vfs.VirtualFile)812 PsiElement (com.intellij.psi.PsiElement)485 File (java.io.File)405 Project (com.intellij.openapi.project.Project)396 PsiFile (com.intellij.psi.PsiFile)320 NotNull (org.jetbrains.annotations.NotNull)259 IOException (java.io.IOException)247 Module (com.intellij.openapi.module.Module)227 ArrayList (java.util.ArrayList)178 TextRange (com.intellij.openapi.util.TextRange)156 Document (com.intellij.openapi.editor.Document)124 List (java.util.List)116 ASTNode (com.intellij.lang.ASTNode)105 IElementType (com.intellij.psi.tree.IElementType)103 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)102 XmlTag (com.intellij.psi.xml.XmlTag)96 Editor (com.intellij.openapi.editor.Editor)94 Element (org.jdom.Element)93 XmlFile (com.intellij.psi.xml.XmlFile)78