本文整理汇总了Java中com.intellij.openapi.vcs.impl.LineStatusTrackerManager类的典型用法代码示例。如果您正苦于以下问题:Java LineStatusTrackerManager类的具体用法?Java LineStatusTrackerManager怎么用?Java LineStatusTrackerManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LineStatusTrackerManager类属于com.intellij.openapi.vcs.impl包,在下文中一共展示了LineStatusTrackerManager类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: update
import com.intellij.openapi.vcs.impl.LineStatusTrackerManager; //导入依赖的package包/类
@Override
public void update(AnActionEvent e) {
Project project = e.getProject();
Editor editor = e.getData(CommonDataKeys.EDITOR);
if (project == null || editor == null) {
e.getPresentation().setEnabledAndVisible(false);
return;
}
if (DiffUtil.isDiffEditor(editor)) {
e.getPresentation().setEnabledAndVisible(false);
return;
}
LineStatusTracker tracker = LineStatusTrackerManager.getInstance(project).getLineStatusTracker(editor.getDocument());
if (tracker == null || tracker.isSilentMode()) {
e.getPresentation().setEnabledAndVisible(false);
return;
}
if (!isSomeChangeSelected(editor, tracker)) {
e.getPresentation().setVisible(true);
e.getPresentation().setEnabled(false);
return;
}
e.getPresentation().setEnabledAndVisible(true);
}
示例2: getRanges
import com.intellij.openapi.vcs.impl.LineStatusTrackerManager; //导入依赖的package包/类
public PreparedFragmentedContent getRanges(Change change) throws VcsException {
FilePath filePath = ChangesUtil.getFilePath(change);
final RangesCalculator calculator = new RangesCalculator();
calculator.execute(change, filePath, myRangesCache, LineStatusTrackerManager.getInstance(myProject));
final VcsException exception = calculator.getException();
if (exception != null) {
LOG.info(exception);
throw exception;
}
List<BeforeAfter<TextRange>> ranges = calculator.getRanges();
if (ranges == null || ranges.isEmpty()) return null;
FragmentedContent fragmentedContent = new FragmentedContent(calculator.getOldDocument(), calculator.getDocument(), ranges, change);
VirtualFile file = filePath.getVirtualFile();
if (file == null) {
file = LocalFileSystem.getInstance().refreshAndFindFileByPath(filePath.getPath());
}
return new PreparedFragmentedContent(myProject, fragmentedContent,
filePath.getName(), filePath.getFileType(),
change.getBeforeRevision() == null ? null : change.getBeforeRevision().getRevisionNumber(),
change.getAfterRevision() == null ? null : change.getAfterRevision().getRevisionNumber(), filePath, file);
}
示例3: ShowChangeMarkerAction
import com.intellij.openapi.vcs.impl.LineStatusTrackerManager; //导入依赖的package包/类
public ShowChangeMarkerAction() {
myChangeMarkerContext = new ChangeMarkerContext() {
public Range getRange(VcsContext context) {
Editor editor = getEditor(context);
if (editor == null) return null;
LineStatusTracker lineStatusTracker = getLineStatusTracker(context);
if (lineStatusTracker == null) return null;
return extractRange(lineStatusTracker, editor.getCaretModel().getLogicalPosition().line, editor);
}
public LineStatusTracker getLineStatusTracker(VcsContext dataContext) {
Editor editor = getEditor(dataContext);
if (editor == null) return null;
Project project = dataContext.getProject();
if (project == null) return null;
return LineStatusTrackerManager.getInstance(project).getLineStatusTracker(editor.getDocument());
}
public Editor getEditor(VcsContext dataContext) {
return dataContext.getEditor();
}
};
}
示例4: update
import com.intellij.openapi.vcs.impl.LineStatusTrackerManager; //导入依赖的package包/类
@Override
public void update(AnActionEvent e) {
Project project = e.getProject();
Editor editor = e.getData(CommonDataKeys.EDITOR);
if (project == null || editor == null) {
e.getPresentation().setEnabledAndVisible(false);
return;
}
if (DiffUtil.isDiffEditor(editor)) {
e.getPresentation().setEnabledAndVisible(false);
return;
}
LineStatusTracker tracker = LineStatusTrackerManager.getInstance(project).getLineStatusTracker(editor.getDocument());
if (tracker == null || !tracker.isValid() || tracker.isSilentMode()) {
e.getPresentation().setEnabledAndVisible(false);
return;
}
if (!isSomeChangeSelected(editor, tracker)) {
e.getPresentation().setVisible(true);
e.getPresentation().setEnabled(false);
return;
}
e.getPresentation().setEnabledAndVisible(true);
}
示例5: getCachedChangedLines
import com.intellij.openapi.vcs.impl.LineStatusTrackerManager; //导入依赖的package包/类
@Nullable
private static List<TextRange> getCachedChangedLines(@NotNull Project project, @NotNull Document document) {
LineStatusTracker tracker = LineStatusTrackerManager.getInstance(project).getLineStatusTracker(document);
if (tracker != null) {
List<Range> ranges = tracker.getRanges();
return getChangedTextRanges(document, ranges);
}
return null;
}
示例6: ShowChangeMarkerAction
import com.intellij.openapi.vcs.impl.LineStatusTrackerManager; //导入依赖的package包/类
public ShowChangeMarkerAction() {
myChangeMarkerContext = new ChangeMarkerContext() {
@Override
public Range getRange(VcsContext context) {
Editor editor = getEditor(context);
if (editor == null) return null;
LineStatusTracker lineStatusTracker = getLineStatusTracker(context);
if (lineStatusTracker == null) return null;
return extractRange(lineStatusTracker, editor.getCaretModel().getLogicalPosition().line, editor);
}
@Override
public LineStatusTracker getLineStatusTracker(VcsContext dataContext) {
Editor editor = getEditor(dataContext);
if (editor == null) return null;
Project project = dataContext.getProject();
if (project == null) return null;
return LineStatusTrackerManager.getInstance(project).getLineStatusTracker(editor.getDocument());
}
@Override
public Editor getEditor(VcsContext dataContext) {
return dataContext.getEditor();
}
};
}
示例7: getRanges
import com.intellij.openapi.vcs.impl.LineStatusTrackerManager; //导入依赖的package包/类
public PreparedFragmentedContent getRanges(Change change) throws VcsException {
final FilePath filePath = ChangesUtil.getFilePath(change);
final RangesCalculator calculator = new RangesCalculator();
calculator.execute(change, filePath, myRangesCache, LineStatusTrackerManager.getInstance(myProject));
final VcsException exception = calculator.getException();
if (exception != null) {
LOG.info(exception);
throw exception;
}
List<BeforeAfter<TextRange>> ranges = calculator.getRanges();
if (ranges == null || ranges.isEmpty()) return null;
FragmentedContent fragmentedContent = new FragmentedContent(calculator.getOldDocument(), calculator.getDocument(), ranges);
final FileStatus fs = change.getFileStatus();
fragmentedContent.setIsAddition(FileStatus.ADDED.equals(fs));
fragmentedContent.setOneSide(FileStatus.ADDED.equals(fs) || FileStatus.DELETED.equals(fs));
VirtualFile file = filePath.getVirtualFile();
if (file == null) {
filePath.hardRefresh();
file = filePath.getVirtualFile();
}
final PreparedFragmentedContent preparedFragmentedContent = new PreparedFragmentedContent(myProject, fragmentedContent,
filePath.getName(), filePath.getFileType(),
change.getBeforeRevision() == null ? null : change.getBeforeRevision().getRevisionNumber(),
change.getAfterRevision() == null ? null : change.getAfterRevision().getRevisionNumber(), filePath, file);
return preparedFragmentedContent;
}
示例8: 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;
}
示例9: 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;
}
示例10: getCachedChangedLines
import com.intellij.openapi.vcs.impl.LineStatusTrackerManager; //导入依赖的package包/类
@Nullable
private static List<TextRange> getCachedChangedLines(@Nonnull Project project, @Nonnull Document document) {
LineStatusTracker tracker = LineStatusTrackerManager.getInstance(project).getLineStatusTracker(document);
if (tracker != null && tracker.isValid()) {
List<Range> ranges = tracker.getRanges();
return getChangedTextRanges(document, ranges);
}
return null;
}