• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java TextFilePatch类的典型用法和代码示例

java 2次浏览

本文整理汇总了Java中com.intellij.openapi.diff.impl.patch.TextFilePatch的典型用法代码示例。如果您正苦于以下问题:Java TextFilePatch类的具体用法?Java TextFilePatch怎么用?Java TextFilePatch使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

TextFilePatch类属于com.intellij.openapi.diff.impl.patch包,在下文中一共展示了TextFilePatch类的31个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: processMatch

点赞 3

import com.intellij.openapi.diff.impl.patch.TextFilePatch; //导入依赖的package包/类
@Nullable
protected TextFilePatchInProgress processMatch(final TextFilePatch patch, final VirtualFile file) {
  final String beforeName = patch.getBeforeName();
  if (beforeName == null) return null;
  final String[] parts = beforeName.replace('\\', '/').split("/");
  VirtualFile parent = file.getParent();
  int idx = parts.length - 2;
  while ((parent != null) && (idx >= 0)) {
    if (!parent.getName().equals(parts[idx])) {
      break;
    }
    parent = parent.getParent();
    --idx;
  }
  if (parent != null) {
    final TextFilePatchInProgress result = new TextFilePatchInProgress(patch, null, myBaseDir);
    result.setNewBase(parent);
    int numDown = idx + 1;
    processStipUp(result, numDown);
    return result;
  }
  return null;
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:24,
代码来源:AutoMatchStrategy.java

示例2: getMatchingLines

点赞 3

import com.intellij.openapi.diff.impl.patch.TextFilePatch; //导入依赖的package包/类
private static int getMatchingLines(final AbstractFilePatchInProgress<TextFilePatch> patch) {
  final VirtualFile base = patch.getCurrentBase();
  if (base == null) return -1;
  String text;
  try {
    if (base.getLength() > BIG_FILE_BOUND) {
      // partially
      text = VfsUtilCore.loadText(base, BIG_FILE_BOUND);
    }
    else {
      text = VfsUtilCore.loadText(base);
    }
  }
  catch (IOException e) {
    return 0;
  }
  return new GenericPatchApplier(text, patch.getPatch().getHunks()).weightContextMatch(100, 5);
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:19,
代码来源:MatchPatchPaths.java

示例3: acceptPatch

点赞 3

import com.intellij.openapi.diff.impl.patch.TextFilePatch; //导入依赖的package包/类
@Override
public void acceptPatch(TextFilePatch patch, Collection<VirtualFile> foundByName) {
  TextFilePatchInProgress longest = null;
  for (VirtualFile file : foundByName) {
    final TextFilePatchInProgress current = processMatch(patch, file);
    if ((current != null) && ((longest == null) || (longest.getCurrentStrip() > current.getCurrentStrip()))) {
      longest = current;
    }
  }
  if (longest != null) {
    registerFolderDecision(longest.getPatch().getBeforeName(), longest.getBase());
    myResult.add(longest);
  } else {
    myResult.add(new TextFilePatchInProgress(patch, null, myBaseDir));
  }
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:17,
代码来源:DefaultPatchStrategy.java

示例4: patchGroupsToOneGroup

点赞 3

import com.intellij.openapi.diff.impl.patch.TextFilePatch; //导入依赖的package包/类
public static List<FilePatch> patchGroupsToOneGroup(MultiMap<VirtualFile, TextFilePatchInProgress> patchGroups, VirtualFile baseDir)
  throws IOException {
  final List<FilePatch> textPatches = new ArrayList<FilePatch>();
  final String baseDirPath = baseDir.getPath();

  for (Map.Entry<VirtualFile, Collection<TextFilePatchInProgress>> entry : patchGroups.entrySet()) {
    final VirtualFile vf = entry.getKey();
    final String currBasePath = vf.getPath();
    final String relativePath = VfsUtilCore.getRelativePath(vf, baseDir, '/');
    final boolean toConvert = !StringUtil.isEmptyOrSpaces(relativePath) && !".".equals(relativePath);
    for (TextFilePatchInProgress patchInProgress : entry.getValue()) {
      final TextFilePatch patch = patchInProgress.getPatch();
      if (toConvert) {
        //correct paths
        patch.setBeforeName(convertRelativePath(patch.getBeforeName(), currBasePath, baseDirPath));
        patch.setAfterName(convertRelativePath(patch.getAfterName(), currBasePath, baseDirPath));
      }
      textPatches.add(patch);
    }
  }
  return textPatches;
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:23,
代码来源:ApplyPatchSaveToFileExecutor.java

示例5: execute

点赞 3

import com.intellij.openapi.diff.impl.patch.TextFilePatch; //导入依赖的package包/类
public String execute(final String text, String patchContent, final String fileName) throws VcsException {
  patchContent = reversePatch(patchContent);
  final PatchReader patchReader = new PatchReader(patchContent);
  try {
    patchReader.parseAllPatches();
  } catch (PatchSyntaxException e) {
    throw new VcsException("Patch syntax exception in: " + fileName, e);
  }
  final List<TextFilePatch> patches = patchReader.getPatches();
  if (patches.size() != 1) throw new VcsException("Not one file patch in provided char sequence in: " + fileName);

  final TextFilePatch patch = patches.get(0);
  final GenericPatchApplier applier = new GenericPatchApplier(text, patch.getHunks());
  if (! applier.execute()) {
    LOG.info("Patch apply problems for: " + fileName);
    applier.trySolveSomehow();
  }
  return applier.getAfter();
}
 

开发者ID:irengrig,
项目名称:fossil4idea,
代码行数:20,
代码来源:DiffUtil.java

示例6: decorate

点赞 3

import com.intellij.openapi.diff.impl.patch.TextFilePatch; //导入依赖的package包/类
public void decorate(Change change, SimpleColoredComponent component, boolean isShowFlatten) {
  if (change instanceof FilePatchInProgress.PatchChange) {
    final FilePatchInProgress.PatchChange patchChange = (FilePatchInProgress.PatchChange) change;
    if (! isShowFlatten) {
      // add change subpath
      final TextFilePatch filePatch = patchChange.getPatchInProgress().getPatch();
      final String patchPath = filePatch.getAfterName() == null ? filePatch.getBeforeName() : filePatch.getAfterName();
      component.append("   ");
      component.append("["+ patchPath + "]", SimpleTextAttributes.GRAY_ATTRIBUTES);
    }
    if (patchChange.getPatchInProgress().getCurrentStrip() > 0) {
      component.append(" stripped " + patchChange.getPatchInProgress().getCurrentStrip(), SimpleTextAttributes.GRAY_ITALIC_ATTRIBUTES);
    }
    final String text;
    if (FilePatchStatus.ADDED.equals(patchChange.getPatchInProgress().getStatus())) {
      text = "(Added)";
    } else if (FilePatchStatus.DELETED.equals(patchChange.getPatchInProgress().getStatus())) {
      text = "(Deleted)";
    } else {
      text = "(Modified)";
    }
    component.append("   ");
    component.append(text, SimpleTextAttributes.GRAY_ATTRIBUTES);
  }
}
 

开发者ID:lshain-android-source,
项目名称:tools-idea,
代码行数:26,
代码来源:ApplyPatchDifferentiatedDialog.java

示例7: processMatch

点赞 3

import com.intellij.openapi.diff.impl.patch.TextFilePatch; //导入依赖的package包/类
@Nullable
protected FilePatchInProgress processMatch(final TextFilePatch patch, final VirtualFile file) {
  final String beforeName = patch.getBeforeName();
  if (beforeName == null) return null;
  final String[] parts = beforeName.replace('\\', '/').split("/");
  VirtualFile parent = file.getParent();
  int idx = parts.length - 2;
  while ((parent != null) && (idx >= 0)) {
    if (! parent.getName().equals(parts[idx])) {
      break;
    }
    parent = parent.getParent();
    -- idx;
  }
  if (parent != null) {
    final FilePatchInProgress result = new FilePatchInProgress(patch, null, myBaseDir);
    result.setNewBase(parent);
    int numDown = idx + 1;
    for (int i = 0; i < numDown; i++) {
      result.up();
    }
    return result;
  }
  return null;
}
 

开发者ID:lshain-android-source,
项目名称:tools-idea,
代码行数:26,
代码来源:AutoMatchStrategy.java

示例8: execute

点赞 3

import com.intellij.openapi.diff.impl.patch.TextFilePatch; //导入依赖的package包/类
public List<FilePatchInProgress> execute(final List<TextFilePatch> list) {
  final PatchBaseDirectoryDetector directoryDetector = PatchBaseDirectoryDetector.getInstance(myProject);
  final Application application = ApplicationManager.getApplication();

  final List<PatchAndVariants> candidates = new ArrayList<PatchAndVariants>(list.size());
  final List<TextFilePatch> newOrWithoutMatches = new ArrayList<TextFilePatch>();
  findCandidates(list, directoryDetector, application, candidates, newOrWithoutMatches);

  final MultiMap<VirtualFile, FilePatchInProgress> result = new MultiMap<VirtualFile, FilePatchInProgress>();
  // process exact matches: if one, leave and extract. if several - leave only them
  filterExactMatches(candidates, result);

  // partially check by context
  selectByContext(candidates, result);
  // created or no variants
  workWithNotExisting(directoryDetector, newOrWithoutMatches, result);
  return new ArrayList<FilePatchInProgress>(result.values());
}
 

开发者ID:lshain-android-source,
项目名称:tools-idea,
代码行数:19,
代码来源:MatchPatchPaths.java

示例9: acceptPatch

点赞 3

import com.intellij.openapi.diff.impl.patch.TextFilePatch; //导入依赖的package包/类
@Override
public void acceptPatch(TextFilePatch patch, Collection<VirtualFile> foundByName) {
  FilePatchInProgress longest = null;
  for (VirtualFile file : foundByName) {
    final FilePatchInProgress current = processMatch(patch, file);
    if ((current != null) && ((longest == null) || (longest.getCurrentStrip() > current.getCurrentStrip()))) {
      longest = current;
    }
  }
  if (longest != null) {
    registerFolderDecision(longest.getPatch().getBeforeName(), longest.getBase());
    myResult.add(longest);
  } else {
    myResult.add(new FilePatchInProgress(patch, null, myBaseDir));
  }
}
 

开发者ID:lshain-android-source,
项目名称:tools-idea,
代码行数:17,
代码来源:DefaultPatchStrategy.java

示例10: getChanges

点赞 3

import com.intellij.openapi.diff.impl.patch.TextFilePatch; //导入依赖的package包/类
public List<ShelvedChange> getChanges(Project project) {
  if (myChanges == null) {
    try {
      final List<TextFilePatch> list = ShelveChangesManager.loadPatches(project, PATH, null);
      myChanges = new ArrayList<ShelvedChange>();
      for (FilePatch patch : list) {
        FileStatus status;
        if (patch.isNewFile()) {
          status = FileStatus.ADDED;
        }
        else if (patch.isDeletedFile()) {
          status = FileStatus.DELETED;
        }
        else {
          status = FileStatus.MODIFIED;
        }
        myChanges.add(new ShelvedChange(PATH, patch.getBeforeName(), patch.getAfterName(), status));
      }
    }
    catch (Exception e) {
      LOG.error(e);
    }
  }
  return myChanges;
}
 

开发者ID:lshain-android-source,
项目名称:tools-idea,
代码行数:26,
代码来源:ShelvedChangeList.java

示例11: patchGroupsToOneGroup

点赞 3

import com.intellij.openapi.diff.impl.patch.TextFilePatch; //导入依赖的package包/类
public static List<FilePatch> patchGroupsToOneGroup(MultiMap<VirtualFile, FilePatchInProgress> patchGroups, VirtualFile baseDir)
  throws IOException {
  final List<FilePatch> textPatches = new ArrayList<FilePatch>();
  final String baseDirPath = baseDir.getPath();

  for (Map.Entry<VirtualFile, Collection<FilePatchInProgress>> entry : patchGroups.entrySet()) {
    final VirtualFile vf = entry.getKey();
    final String currBasePath = vf.getPath();
    final String relativePath = VfsUtil.getRelativePath(vf, baseDir, '/');
    final boolean toConvert = !StringUtil.isEmptyOrSpaces(relativePath) && !".".equals(relativePath);
    for (FilePatchInProgress patchInProgress : entry.getValue()) {
      final TextFilePatch patch = patchInProgress.getPatch();
      if (toConvert) {
        //correct paths
        patch.setBeforeName(convertRelativePath(patch.getBeforeName(), currBasePath, baseDirPath));
        patch.setAfterName(convertRelativePath(patch.getAfterName(), currBasePath, baseDirPath));
      }
      textPatches.add(patch);
    }
  }
  return textPatches;
}
 

开发者ID:lshain-android-source,
项目名称:tools-idea,
代码行数:23,
代码来源:ApplyPatchSaveToFileExecutor.java

示例12: create

点赞 2

import com.intellij.openapi.diff.impl.patch.TextFilePatch; //导入依赖的package包/类
@NotNull
public static ApplyPatchForBaseRevisionTexts create(final Project project, final VirtualFile file, final FilePath pathBeforeRename,
                                                     final TextFilePatch patch, final Getter<CharSequence> baseContents) {
  assert ! patch.isNewFile();
  final String beforeVersionId = patch.getBeforeVersionId();
  DefaultPatchBaseVersionProvider provider = null;
  if (beforeVersionId != null) {
    provider = new DefaultPatchBaseVersionProvider(project, file, beforeVersionId);
  }
  if (provider != null && provider.canProvideContent()) {
    return new ApplyPatchForBaseRevisionTexts(provider, pathBeforeRename, patch, file, baseContents);
  } else {
    return new ApplyPatchForBaseRevisionTexts(null, pathBeforeRename, patch, file, baseContents);
  }
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:16,
代码来源:ApplyPatchForBaseRevisionTexts.java

示例13: suggestFolderForCreation

点赞 2

import com.intellij.openapi.diff.impl.patch.TextFilePatch; //导入依赖的package包/类
@Nullable
protected Collection<VirtualFile> suggestFolderForCreation(final TextFilePatch creation) {
  final String newFileParentPath = extractPathWithoutName(creation.getAfterName());
  if (newFileParentPath != null) {
    return filterVariants(creation, myFolderDecisions.get(newFileParentPath));
  }
  return null;
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:9,
代码来源:AutoMatchStrategy.java

示例14: processCreationBasedOnFolderDecisions

点赞 2

import com.intellij.openapi.diff.impl.patch.TextFilePatch; //导入依赖的package包/类
protected void processCreationBasedOnFolderDecisions(final TextFilePatch creation) {
  final Collection<VirtualFile> variants = suggestFolderForCreation(creation);
  if (variants != null) {
    myResult.add(new TextFilePatchInProgress(creation, variants, myBaseDir));
  }
  else {
    myResult.add(new TextFilePatchInProgress(creation, null, myBaseDir));
  }
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:10,
代码来源:AutoMatchStrategy.java

示例15: filterVariants

点赞 2

import com.intellij.openapi.diff.impl.patch.TextFilePatch; //导入依赖的package包/类
protected Collection<VirtualFile> filterVariants(final TextFilePatch patch, final Collection<VirtualFile> in) {
  String path = patch.getBeforeName() == null ? patch.getAfterName() : patch.getBeforeName();
  path = path.replace("\\", "/");

  final boolean caseSensitive = SystemInfo.isFileSystemCaseSensitive;
  final Collection<VirtualFile> result = new LinkedList<VirtualFile>();
  for (VirtualFile vf : in) {
    final String vfPath = vf.getPath();
    if ((caseSensitive && vfPath.endsWith(path)) || ((!caseSensitive) && StringUtil.endsWithIgnoreCase(vfPath, path))) {
      result.add(vf);
    }
  }
  return result;
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:15,
代码来源:AutoMatchStrategy.java

示例16: acceptPatch

点赞 2

import com.intellij.openapi.diff.impl.patch.TextFilePatch; //导入依赖的package包/类
@Override
public void acceptPatch(TextFilePatch patch, Collection<VirtualFile> foundByName) {
  if (! mySucceeded) return;

  final Collection<VirtualFile> variants = filterVariants(patch, foundByName);

  if ((variants != null) && (! variants.isEmpty())) {
    final TextFilePatchInProgress textFilePatchInProgress = new TextFilePatchInProgress(patch, variants, myBaseDir);
    myResult.add(textFilePatchInProgress);
    registerFolderDecision(patch.getBeforeName(), textFilePatchInProgress.getBase());
  } else {
    mySucceeded = false;
  }
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:15,
代码来源:IndividualPiecesStrategy.java

示例17: processCreation

点赞 2

import com.intellij.openapi.diff.impl.patch.TextFilePatch; //导入依赖的package包/类
@Override
public void processCreation(TextFilePatch creation) {
  if (! mySucceeded) return;
  final TextFilePatchInProgress textFilePatchInProgress;
  if (myVariants.isEmpty()) {
    textFilePatchInProgress = new TextFilePatchInProgress(creation, null, myBaseDir);
  } else {
    textFilePatchInProgress = new TextFilePatchInProgress(creation, null, myVariants.keySet().iterator().next());
  }
  myResult.add(textFilePatchInProgress);
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:12,
代码来源:OneBaseStrategy.java

示例18: loadFilePatch

点赞 2

import com.intellij.openapi.diff.impl.patch.TextFilePatch; //导入依赖的package包/类
@Nullable
public TextFilePatch loadFilePatch(final Project project, CommitContext commitContext) throws IOException, PatchSyntaxException {
  List<TextFilePatch> filePatches = ShelveChangesManager.loadPatches(project, myPatchPath, commitContext);
  for(TextFilePatch patch: filePatches) {
    if (myBeforePath.equals(patch.getBeforeName())) {
      return patch;
    }
  }
  return null;
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:11,
代码来源:ShelvedChange.java

示例19: loadContent

点赞 2

import com.intellij.openapi.diff.impl.patch.TextFilePatch; //导入依赖的package包/类
@Nullable
private String loadContent() throws IOException, PatchSyntaxException, ApplyPatchException {
  TextFilePatch patch = loadFilePatch(myProject, null);
  if (patch != null) {
    return loadContent(patch);
  }
  return null;
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:9,
代码来源:ShelvedChange.java

示例20: addPatch

点赞 2

import com.intellij.openapi.diff.impl.patch.TextFilePatch; //导入依赖的package包/类
private void addPatch(final FilePatch patch, final VirtualFile file) {
  final Pair<VirtualFile, ApplyFilePatchBase> patchPair = Pair.create(file, ApplyFilePatchFactory.createGeneral(patch));
  if (patch instanceof TextFilePatch) {
    myTextPatches.add(Pair.create(file, ApplyFilePatchFactory.create((TextFilePatch)patch)));
  } else {
    final ApplyFilePatchBase<BinaryType> applyBinaryPatch = (ApplyFilePatchBase<BinaryType>)((patch instanceof BinaryFilePatch)
                                                                                             ? ApplyFilePatchFactory
                                                                                               .create((BinaryFilePatch)patch)
                                                                                             :
                                                                                             ApplyFilePatchFactory.create(
                                                                                               (ShelveChangesManager.ShelvedBinaryFilePatch)patch));
    myBinaryPatches.add(Pair.create(file, applyBinaryPatch));
  }
  myWritableFiles.add(file);
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:16,
代码来源:PathsVerifier.java

示例21: createGeneral

点赞 2

import com.intellij.openapi.diff.impl.patch.TextFilePatch; //导入依赖的package包/类
public static ApplyFilePatchBase createGeneral(final FilePatch patch) {
  if (patch instanceof TextFilePatch) {
    return create((TextFilePatch) patch);
  } else if (patch instanceof BinaryFilePatch) {
    return create((BinaryFilePatch) patch);
  } else if (patch instanceof ShelveChangesManager.ShelvedBinaryFilePatch) {
    return create((ShelveChangesManager.ShelvedBinaryFilePatch) patch);
  }
  throw new IllegalStateException();
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:11,
代码来源:ApplyFilePatchFactory.java

示例22: init

点赞 2

import com.intellij.openapi.diff.impl.patch.TextFilePatch; //导入依赖的package包/类
private void init(List<TextFilePatch> patches, final LocalChangeList localChangeList) {
  final List<FilePatchInProgress> matchedPathes = new MatchPatchPaths(myProject).execute(patches);

  SwingUtilities.invokeLater(new Runnable() {
    public void run() {
      if (localChangeList != null) {
        myChangeListChooser.setDefaultSelection(localChangeList);
      }

      myPatches.clear();
      myPatches.addAll(matchedPathes);
      updateTree(true);
    }
  });
}
 

开发者ID:lshain-android-source,
项目名称:tools-idea,
代码行数:16,
代码来源:ApplyPatchDifferentiatedDialog.java

示例23: showDiff

点赞 2

import com.intellij.openapi.diff.impl.patch.TextFilePatch; //导入依赖的package包/类
private void showDiff() {
  if (ChangeListManager.getInstance(myProject).isFreezedWithNotification(null)) return;
  if (myPatches.isEmpty() || (! myContainBasedChanges)) return;
  final List<FilePatchInProgress.PatchChange> changes = getAllChanges();
  Collections.sort(changes, myMyChangeComparator);
  final List<FilePatchInProgress.PatchChange> selectedChanges = myChangesTreeList.getSelectedChanges();

  int selectedIdx = 0;
  final ArrayList<DiffRequestPresentable> diffRequestPresentables = new ArrayList<DiffRequestPresentable>(changes.size());
  if (selectedChanges.isEmpty()) {
    selectedChanges.addAll(changes);
  }
  if (! selectedChanges.isEmpty()) {
    final FilePatchInProgress.PatchChange c = selectedChanges.get(0);
    for (FilePatchInProgress.PatchChange change : changes) {
      final FilePatchInProgress patchInProgress = change.getPatchInProgress();
      if (! patchInProgress.baseExistsOrAdded()) continue;
      final TextFilePatch patch = patchInProgress.getPatch();
      final String path = patch.getBeforeName() == null ? patch.getAfterName() : patch.getBeforeName();
      final DiffRequestPresentable diffRequestPresentable =
        change.createDiffRequestPresentable(myProject, new Getter<CharSequence>() {
          @Override
          public CharSequence get() {
            return myReader.getBaseRevision(myProject, path);
          }
        });
      if (diffRequestPresentable != null) {
        diffRequestPresentables.add(diffRequestPresentable);
      }
      if (change.equals(c)) {
        selectedIdx = diffRequestPresentables.size() - 1;
      }
    }
  }
  if (diffRequestPresentables.isEmpty()) return;
  ShowDiffAction.showDiffImpl(myProject, diffRequestPresentables, selectedIdx, new ShowDiffUIContext(false));
}
 

开发者ID:lshain-android-source,
项目名称:tools-idea,
代码行数:38,
代码来源:ApplyPatchDifferentiatedDialog.java

示例24: FilePatchInProgress

点赞 2

import com.intellij.openapi.diff.impl.patch.TextFilePatch; //导入依赖的package包/类
public FilePatchInProgress(final TextFilePatch patch, final Collection<VirtualFile> autoBases, final VirtualFile baseDir) {
  myPatch = patch.pathsOnlyCopy();
  myStrippable = new PatchStrippable(patch);
  myAutoBases = new ArrayList<VirtualFile>();
  if (autoBases != null) {
    setAutoBases(autoBases);
  }
  myStatus = getStatus(myPatch);
  if (myAutoBases.isEmpty()) {
    setNewBase(baseDir);
  } else {
    setNewBase(myAutoBases.get(0));
  }
}
 

开发者ID:lshain-android-source,
项目名称:tools-idea,
代码行数:15,
代码来源:FilePatchInProgress.java

示例25: getStatus

点赞 2

import com.intellij.openapi.diff.impl.patch.TextFilePatch; //导入依赖的package包/类
private static FilePatchStatus getStatus(final TextFilePatch patch) {
  final String beforeName = patch.getBeforeName().replace("\\", "/");
  final String afterName = patch.getAfterName().replace("\\", "/");
  
  if (patch.isNewFile() || (beforeName == null)) {
    return FilePatchStatus.ADDED;
  } else if (patch.isDeletedFile() || (afterName == null)) {
    return FilePatchStatus.DELETED;
  }

  if (beforeName.equals(afterName)) return FilePatchStatus.MODIFIED;
  return FilePatchStatus.MOVED_OR_RENAMED;
}
 

开发者ID:lshain-android-source,
项目名称:tools-idea,
代码行数:14,
代码来源:FilePatchInProgress.java

示例26: processCreationBasedOnFolderDecisions

点赞 2

import com.intellij.openapi.diff.impl.patch.TextFilePatch; //导入依赖的package包/类
protected void processCreationBasedOnFolderDecisions(final TextFilePatch creation) {
  final Collection<VirtualFile> variants = suggestFolderForCreation(creation);
  if (variants != null) {
    myResult.add(new FilePatchInProgress(creation, variants, myBaseDir));
  } else {
    myResult.add(new FilePatchInProgress(creation, null, myBaseDir));
  }
}
 

开发者ID:lshain-android-source,
项目名称:tools-idea,
代码行数:9,
代码来源:AutoMatchStrategy.java

示例27: filterVariants

点赞 2

import com.intellij.openapi.diff.impl.patch.TextFilePatch; //导入依赖的package包/类
protected Collection<VirtualFile> filterVariants(final TextFilePatch patch, final Collection<VirtualFile> in) {
  String path = patch.getBeforeName() == null ? patch.getAfterName() : patch.getBeforeName();
  path = path.replace("\\", "/");

  final boolean caseSensitive = SystemInfo.isFileSystemCaseSensitive;
  final Collection<VirtualFile> result = new LinkedList<VirtualFile>();
  for (VirtualFile vf : in) {
    final String vfPath = vf.getPath();
    if ((caseSensitive && vfPath.endsWith(path)) || ((! caseSensitive) && StringUtil.endsWithIgnoreCase(vfPath, path))) {
      result.add(vf);
    }
  }
  return result;
}
 

开发者ID:lshain-android-source,
项目名称:tools-idea,
代码行数:15,
代码来源:AutoMatchStrategy.java

示例28: acceptPatch

点赞 2

import com.intellij.openapi.diff.impl.patch.TextFilePatch; //导入依赖的package包/类
@Override
public void acceptPatch(TextFilePatch patch, Collection<VirtualFile> foundByName) {
  if (! mySucceeded) return;

  final Collection<VirtualFile> variants = filterVariants(patch, foundByName);

  if ((variants != null) && (! variants.isEmpty())) {
    final FilePatchInProgress filePatchInProgress = new FilePatchInProgress(patch, variants, myBaseDir);
    myResult.add(filePatchInProgress);
    registerFolderDecision(patch.getBeforeName(), filePatchInProgress.getBase());
  } else {
    mySucceeded = false;
  }
}
 

开发者ID:lshain-android-source,
项目名称:tools-idea,
代码行数:15,
代码来源:IndividualPiecesStrategy.java

示例29: findCandidates

点赞 2

import com.intellij.openapi.diff.impl.patch.TextFilePatch; //导入依赖的package包/类
private void findCandidates(List<TextFilePatch> list,
                            final PatchBaseDirectoryDetector directoryDetector,
                            Application application,
                            List<PatchAndVariants> candidates, List<TextFilePatch> newOrWithoutMatches) {
  for (final TextFilePatch patch : list) {
    final String fileName = patch.getBeforeFileName();
    if (patch.isNewFile() || (patch.getBeforeName() == null)) {
      newOrWithoutMatches.add(patch);
      continue;
    }
    final Collection<VirtualFile> files = application.runReadAction(new Computable<Collection<VirtualFile>>() {
      public Collection<VirtualFile> compute() {
        return directoryDetector.findFiles(fileName);
      }
    });
    // for directories outside the project scope but under version control
    if (patch.getBeforeName() != null && patch.getBeforeName().startsWith("..")) {
      final VirtualFile relativeFile = VfsUtil.findRelativeFile(myBaseDir, patch.getBeforeName().replace('\\', '/').split("/"));
      if (relativeFile != null) {
        files.add(relativeFile);
      }
    }
    if (files.isEmpty()) {
      newOrWithoutMatches.add(patch);
    } else {
      final List<FilePatchInProgress> variants = ObjectsConvertor.convert(files, new Convertor<VirtualFile, FilePatchInProgress>() {
        @Override
        public FilePatchInProgress convert(VirtualFile o) {
          return processMatch(patch, o);
        }
      }, ObjectsConvertor.NOT_NULL);
      if (variants.isEmpty()) {
        newOrWithoutMatches.add(patch); // just to be sure
      } else {
        candidates.add(new PatchAndVariants(patch, variants));
      }
    }
  }
}
 

开发者ID:lshain-android-source,
项目名称:tools-idea,
代码行数:40,
代码来源:MatchPatchPaths.java

示例30: processMatch

点赞 2

import com.intellij.openapi.diff.impl.patch.TextFilePatch; //导入依赖的package包/类
@Nullable
private FilePatchInProgress processMatch(final TextFilePatch patch, final VirtualFile file) {
  final String beforeName = patch.getBeforeName();
  /*if (beforeName == null) return null;
  final String[] parts = beforeName.replace('\\', '/').split("/");
  VirtualFile parent = file.getParent();
  int idx = parts.length - 2;
  while ((parent != null) && (idx >= 0)) {
    if (! parent.getName().equals(parts[idx])) {
      break;
    }
    parent = parent.getParent();
    -- idx;
  }*/
  final Pair<VirtualFile, Integer> pair = compareNames(beforeName, file);
  if (pair == null) return null;
  final VirtualFile parent = pair.getFirst();
  if (parent != null) {
    final FilePatchInProgress result = new FilePatchInProgress(patch, null, myBaseDir);
    result.setNewBase(parent);
    int numDown = pair.getSecond();
    for (int i = 0; i < numDown; i++) {
      result.up();
    }
    return result;
  }
  return null;
}
 

开发者ID:lshain-android-source,
项目名称:tools-idea,
代码行数:29,
代码来源:MatchPatchPaths.java

示例31: processCreation

点赞 2

import com.intellij.openapi.diff.impl.patch.TextFilePatch; //导入依赖的package包/类
@Override
public void processCreation(TextFilePatch creation) {
  if (! mySucceeded) return;
  final FilePatchInProgress filePatchInProgress;
  if (myVariants.isEmpty()) {
    filePatchInProgress = new FilePatchInProgress(creation, null, myBaseDir);
  } else {
    filePatchInProgress = new FilePatchInProgress(creation, null, myVariants.keySet().iterator().next());
  }
  myResult.add(filePatchInProgress);
}
 

开发者ID:lshain-android-source,
项目名称:tools-idea,
代码行数:12,
代码来源:OneBaseStrategy.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)