[patch]: add annotation - commitContext can be null

This commit is contained in:
Nadya Zabrodina
2017-06-02 19:54:35 +03:00
parent 36d5139503
commit 42c8e4880c
4 changed files with 11 additions and 11 deletions
@@ -39,12 +39,12 @@ public interface PatchEP {
* @param path - before path, if exist, otherwise after path
* @param commitContext
*/
void consumeContent(@NotNull final String path, @NotNull final CharSequence content, CommitContext commitContext);
void consumeContent(@NotNull final String path, @NotNull final CharSequence content, @Nullable CommitContext commitContext);
/**
* @param path - before path, if exist, otherwise after path
* @param commitContext
*/
void consumeContentBeforePatchApplied(@NotNull final String path,
@NotNull final CharSequence content,
CommitContext commitContext);
@Nullable CommitContext commitContext);
}
@@ -87,7 +87,7 @@ public class ApplyPatchDefaultExecutor implements ApplyPatchExecutor<AbstractFil
public static void applyAdditionalInfoBefore(final Project project,
@Nullable ThrowableComputable<Map<String, Map<String, CharSequence>>, PatchSyntaxException> additionalInfo,
CommitContext commitContext) {
@Nullable CommitContext commitContext) {
applyAdditionalInfoImpl(project, additionalInfo, commitContext,
infoGroup -> infoGroup.myPatchEP.consumeContentBeforePatchApplied(infoGroup.myPath, infoGroup.myContent, infoGroup.myCommitContext));
}
@@ -101,7 +101,7 @@ public class ApplyPatchDefaultExecutor implements ApplyPatchExecutor<AbstractFil
private static void applyAdditionalInfoImpl(final Project project,
@Nullable ThrowableComputable<Map<String, Map<String, CharSequence>>, PatchSyntaxException> additionalInfo,
CommitContext commitContext, final Consumer<InfoGroup> worker) {
@Nullable CommitContext commitContext, final Consumer<InfoGroup> worker) {
final PatchEP[] extensions = Extensions.getExtensions(PatchEP.EP_NAME, project);
if (extensions.length == 0) return;
if (additionalInfo != null) {
@@ -129,9 +129,9 @@ public class ApplyPatchDefaultExecutor implements ApplyPatchExecutor<AbstractFil
private final PatchEP myPatchEP;
private final String myPath;
private final CharSequence myContent;
private final CommitContext myCommitContext;
@Nullable private final CommitContext myCommitContext;
private InfoGroup(PatchEP patchEP, String path, CharSequence content, CommitContext commitContext) {
private InfoGroup(PatchEP patchEP, String path, CharSequence content, @Nullable CommitContext commitContext) {
myPatchEP = patchEP;
myPath = path;
myContent = content;
@@ -310,7 +310,7 @@ public class DiffShelvedChangesActionProvider implements AnActionExtensionProvid
@NotNull
@CalledInBackground
public TextFilePatch getPatch(final ShelvedChange shelvedChange, @NotNull CommitContext commitContext) throws VcsException {
public TextFilePatch getPatch(final ShelvedChange shelvedChange, @Nullable CommitContext commitContext) throws VcsException {
String patchPath = shelvedChange.getPatchPath();
if (getInfoFromCache(patchPath) == null || isPatchFileChanged(patchPath)) {
readFilePatchAndUpdateCaches(patchPath, commitContext);
@@ -336,7 +336,7 @@ public class DiffShelvedChangesActionProvider implements AnActionExtensionProvid
}
}
private void readFilePatchAndUpdateCaches(@NotNull String patchPath, @NotNull CommitContext commitContext) throws VcsException {
private void readFilePatchAndUpdateCaches(@NotNull String patchPath, @Nullable CommitContext commitContext) throws VcsException {
try {
myLock.writeLock().lock();
myFilePatchesMap.put(patchPath, new PatchInfo(ShelveChangesManager.loadPatches(myProject, patchPath, commitContext),
@@ -1036,20 +1036,20 @@ public class ShelveChangesManager extends AbstractProjectComponent implements JD
@NotNull
public static List<TextFilePatch> loadPatches(Project project,
final String patchPath,
CommitContext commitContext) throws IOException, PatchSyntaxException {
@Nullable CommitContext commitContext) throws IOException, PatchSyntaxException {
return loadPatches(project, patchPath, commitContext, true);
}
@NotNull
static List<? extends FilePatch> loadPatchesWithoutContent(Project project,
final String patchPath,
CommitContext commitContext) throws IOException, PatchSyntaxException {
@Nullable CommitContext commitContext) throws IOException, PatchSyntaxException {
return loadPatches(project, patchPath, commitContext, false);
}
private static List<TextFilePatch> loadPatches(Project project,
final String patchPath,
CommitContext commitContext,
@Nullable CommitContext commitContext,
boolean loadContent) throws IOException, PatchSyntaxException {
char[] text = FileUtil.loadFileText(new File(patchPath), CharsetToolkit.UTF8);
PatchReader reader = new PatchReader(new CharArrayCharSequence(text), loadContent);