本文整理汇总了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;
}
示例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;
}