当前位置: 首页>>代码示例>>Java>>正文


Java LineStatusTrackerManager.getInstance方法代码示例

本文整理汇总了Java中com.intellij.openapi.vcs.impl.LineStatusTrackerManager.getInstance方法的典型用法代码示例。如果您正苦于以下问题:Java LineStatusTrackerManager.getInstance方法的具体用法?Java LineStatusTrackerManager.getInstance怎么用?Java LineStatusTrackerManager.getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.openapi.vcs.impl.LineStatusTrackerManager的用法示例。


在下文中一共展示了LineStatusTrackerManager.getInstance方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: hasChanges

import com.intellij.openapi.vcs.impl.LineStatusTrackerManager; //导入方法依赖的package包/类
/**
 * Allows to answer if given file has changes in comparison with VCS.
 * 
 * @param file  target file
 * @return      <code>true</code> if given file has changes; <code>false</code> otherwise
 */
public static boolean hasChanges(@NotNull PsiFile file) {
  final Project project = file.getProject();
  final VirtualFile virtualFile = file.getVirtualFile();
  if (virtualFile != null) {
    final Change change = ChangeListManager.getInstance(project).getChange(virtualFile);
    if (change != null && change.getType() == Change.Type.NEW) {
      return true;
    }
  }

  final LineStatusTrackerManagerI manager = LineStatusTrackerManager.getInstance(project);
  if (manager == null) {
    return false;
  }
  
  final Document document = PsiDocumentManager.getInstance(project).getDocument(file);
  if (document == null) {
    return false;
  }
  final LineStatusTracker lineStatusTracker = manager.getLineStatusTracker(document);
  if (lineStatusTracker == null) {
    return false;
  }
  final List<Range> ranges = lineStatusTracker.getRanges();
  if (ranges == null || ranges.isEmpty()) {
    return false;
  } 
  for (Range range : ranges) {
    if (range.getType() != Range.DELETED) {
      return true;
    }
  }
  return false;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:41,代码来源:FormatChangedTextUtil.java

示例2: getChanges

import com.intellij.openapi.vcs.impl.LineStatusTrackerManager; //导入方法依赖的package包/类
/**
 * Allows to ask for the changed text of the given file (in comparison with VCS).
 * 
 * @param file  target file
 * @return      collection of changed regions for the given file
 */
@NotNull
public static Collection<TextRange> getChanges(@NotNull PsiFile file) {
  final Set<TextRange> defaultResult = Collections.singleton(file.getTextRange());
  final VirtualFile virtualFile = file.getVirtualFile();
  if (virtualFile != null) {
    final Change change = ChangeListManager.getInstance(file.getProject()).getChange(virtualFile);
    if (change != null && change.getType() == Change.Type.NEW) {
      return defaultResult;
    }
  }

  final LineStatusTrackerManagerI manager = LineStatusTrackerManager.getInstance(file.getProject());
  if (manager == null) {
    return defaultResult;
  }
  final Document document = PsiDocumentManager.getInstance(file.getProject()).getDocument(file);
  if (document == null) {
    return defaultResult;
  }
  final LineStatusTracker lineStatusTracker = manager.getLineStatusTracker(document);
  if (lineStatusTracker == null) {
    return defaultResult;
  }
  final List<Range> ranges = lineStatusTracker.getRanges();
  if (ranges == null || ranges.isEmpty()) {
    return defaultResult;
  }
  
  List<TextRange> result = new ArrayList<TextRange>();
  for (Range range : ranges) {
    if (range.getType() != Range.DELETED) {
      final RangeHighlighter highlighter = range.getHighlighter();
      if (highlighter != null) {
        result.add(new TextRange(highlighter.getStartOffset(), highlighter.getEndOffset()));
      }
    }
  }
  return result;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:46,代码来源:FormatChangedTextUtil.java


注:本文中的com.intellij.openapi.vcs.impl.LineStatusTrackerManager.getInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。