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;
}
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);
}
};
}
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);
}
}
};
}
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;
}
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;
}
Aggregations