use of com.intellij.diff.chains.DiffRequestProducer in project intellij-community by JetBrains.
the class TextFilePatchInProgress method getDiffRequestProducers.
@NotNull
@Override
public DiffRequestProducer getDiffRequestProducers(final Project project, final PatchReader patchReader) {
final PatchChange change = getChange();
final FilePatch patch = getPatch();
final String path = patch.getBeforeName() == null ? patch.getAfterName() : patch.getBeforeName();
final Getter<CharSequence> baseContentGetter = new Getter<CharSequence>() {
@Override
public CharSequence get() {
return patchReader.getBaseRevision(project, path);
}
};
return new DiffRequestProducer() {
@NotNull
@Override
public DiffRequest process(@NotNull UserDataHolder context, @NotNull ProgressIndicator indicator) throws DiffRequestProducerException, ProcessCanceledException {
if (myCurrentBase != null && myCurrentBase.getFileType() == UnknownFileType.INSTANCE) {
return new UnknownFileTypeDiffRequest(myCurrentBase, getName());
}
if (isConflictingChange()) {
final VirtualFile file = getCurrentBase();
Getter<ApplyPatchForBaseRevisionTexts> getter = new Getter<ApplyPatchForBaseRevisionTexts>() {
@Override
public ApplyPatchForBaseRevisionTexts get() {
return ApplyPatchForBaseRevisionTexts.create(project, file, VcsUtil.getFilePath(file), getPatch(), baseContentGetter);
}
};
String afterTitle = getPatch().getAfterVersionId();
if (afterTitle == null)
afterTitle = "Patched Version";
return PatchDiffRequestFactory.createConflictDiffRequest(project, file, getPatch(), afterTitle, getter, getName(), context, indicator);
} else {
return PatchDiffRequestFactory.createDiffRequest(project, change, getName(), context, indicator);
}
}
@NotNull
@Override
public String getName() {
final File ioCurrentBase = getIoCurrentBase();
return ioCurrentBase == null ? getCurrentPath() : ioCurrentBase.getPath();
}
};
}
use of com.intellij.diff.chains.DiffRequestProducer in project intellij-community by JetBrains.
the class ExternalDiffTool method collectRequests.
@NotNull
private static List<DiffRequest> collectRequests(@Nullable Project project, @NotNull final DiffRequestChain chain, @NotNull ProgressIndicator indicator) {
List<DiffRequest> requests = new ArrayList<>();
UserDataHolderBase context = new UserDataHolderBase();
List<String> errorRequests = new ArrayList<>();
// TODO: show all changes on explicit selection
List<? extends DiffRequestProducer> producers = Collections.singletonList(chain.getRequests().get(chain.getIndex()));
for (DiffRequestProducer producer : producers) {
try {
requests.add(producer.process(context, indicator));
} catch (DiffRequestProducerException e) {
LOG.warn(e);
errorRequests.add(producer.getName());
}
}
if (!errorRequests.isEmpty()) {
new Notification("diff", "Can't load some changes", StringUtil.join(errorRequests, "<br>"), NotificationType.ERROR).notify(project);
}
return requests;
}
use of com.intellij.diff.chains.DiffRequestProducer in project intellij-community by JetBrains.
the class ApplyPatchDifferentiatedDialog method createBaseNotFoundErrorRequest.
@NotNull
private static DiffRequestProducer createBaseNotFoundErrorRequest(@NotNull final AbstractFilePatchInProgress patchInProgress) {
final String beforePath = patchInProgress.getPatch().getBeforeName();
final String afterPath = patchInProgress.getPatch().getAfterName();
return new DiffRequestProducer() {
@NotNull
@Override
public String getName() {
final File ioCurrentBase = patchInProgress.getIoCurrentBase();
return ioCurrentBase == null ? patchInProgress.getCurrentPath() : ioCurrentBase.getPath();
}
@NotNull
@Override
public DiffRequest process(@NotNull UserDataHolder context, @NotNull ProgressIndicator indicator) throws DiffRequestProducerException, ProcessCanceledException {
throw new DiffRequestProducerException("Cannot find base for '" + (beforePath != null ? beforePath : afterPath) + "'");
}
};
}
Aggregations