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

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

java 1次浏览

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

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

示例1: highlightTodos

点赞 3

import com.intellij.psi.search.PsiTodoSearchHelper; //导入依赖的package包/类
static void highlightTodos(@NotNull PsiFile file,
                           @NotNull CharSequence text,
                           int startOffset,
                           int endOffset,
                           @NotNull ProgressIndicator progress,
                           @NotNull ProperTextRange priorityRange,
                           @NotNull Collection<HighlightInfo> insideResult,
                           @NotNull Collection<HighlightInfo> outsideResult) {
  PsiTodoSearchHelper helper = PsiTodoSearchHelper.SERVICE.getInstance(file.getProject());
  if (helper == null) return;
  TodoItem[] todoItems = helper.findTodoItems(file, startOffset, endOffset);
  if (todoItems.length == 0) return;

  for (TodoItem todoItem : todoItems) {
    progress.checkCanceled();
    TextRange range = todoItem.getTextRange();
    String description = text.subSequence(range.getStartOffset(), range.getEndOffset()).toString();
    TextAttributes attributes = todoItem.getPattern().getAttributes().getTextAttributes();
    HighlightInfo.Builder builder = HighlightInfo.newHighlightInfo(HighlightInfoType.TODO).range(range);
    builder.textAttributes(attributes);
    builder.descriptionAndTooltip(description);
    HighlightInfo info = builder.createUnconditionally();
    (priorityRange.containsRange(info.getStartOffset(), info.getEndOffset()) ? insideResult : outsideResult).add(info);
  }
}
 

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

示例2: checkFile

点赞 3

import com.intellij.psi.search.PsiTodoSearchHelper; //导入依赖的package包/类
@Nullable
@Override
public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) {
  final TodoItem[] todoItems = PsiTodoSearchHelper.SERVICE.getInstance(file.getProject()).findTodoItems(file);

  final List<ProblemDescriptor> result = new ArrayList<ProblemDescriptor>();
  final THashSet<PsiComment> comments = new THashSet<PsiComment>();
  for (TodoItem todoItem : todoItems) {
    final PsiComment comment =
      PsiTreeUtil.getParentOfType(file.findElementAt(todoItem.getTextRange().getStartOffset()), PsiComment.class, false);
    if (comment != null && comments.add(comment)) {
      result.add(manager.createProblemDescriptor(comment, InspectionsBundle.message("todo.comment.problem.descriptor"), isOnTheFly,
                                                 null, ProblemHighlightType.GENERIC_ERROR_OR_WARNING));
    }
  }
  return result.toArray(new ProblemDescriptor[result.size()]);
}
 

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

示例3: findAllTodos

点赞 3

import com.intellij.psi.search.PsiTodoSearchHelper; //导入依赖的package包/类
public static TodoItem[] findAllTodos(final PsiFile psiFile, final PsiTodoSearchHelper helper) {
  final List<TodoItem> todoItems = new ArrayList<TodoItem>(Arrays.asList(helper.findTodoItems(psiFile)));

  psiFile.accept(new PsiRecursiveElementWalkingVisitor() {
    @Override
    public void visitElement(PsiElement element) {
      if (element instanceof PsiLanguageInjectionHost) {
        InjectedLanguageUtil.enumerate(element, new PsiLanguageInjectionHost.InjectedPsiVisitor() {
          @Override
          public void visit(@NotNull PsiFile injectedPsi, @NotNull List<PsiLanguageInjectionHost.Shred> places) {
            if (places.size() == 1) {
              Document document = PsiDocumentManager.getInstance(injectedPsi.getProject()).getCachedDocument(injectedPsi);
              if (!(document instanceof DocumentWindow)) return;
              for (TodoItem item : helper.findTodoItems(injectedPsi)) {
                TextRange rangeInHost = ((DocumentWindow)document).injectedToHost(item.getTextRange());
                todoItems.add(new TodoItemImpl(psiFile, rangeInHost.getStartOffset(), rangeInHost.getEndOffset(), item.getPattern()));
              }
            }
          }
        });
      }
      super.visitElement(element);
    }
  });
  return todoItems.toArray(new TodoItem[todoItems.size()]);
}
 

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

示例4: TodoTreeBuilder

点赞 3

import com.intellij.psi.search.PsiTodoSearchHelper; //导入依赖的package包/类
TodoTreeBuilder(JTree tree, DefaultTreeModel treeModel, Project project) {
  super(tree, treeModel, null, MyComparator.ourInstance, false);
  myProject = project;

  myFileTree = new FileTree();
  myDirtyFileSet = new HashSet<VirtualFile>();

  myFile2Highlighter = new HashMap<VirtualFile, EditorHighlighter>();

  PsiManager psiManager = PsiManager.getInstance(myProject);
  mySearchHelper = PsiTodoSearchHelper.SERVICE.getInstance(myProject);
  psiManager.addPsiTreeChangeListener(new MyPsiTreeChangeListener());

  myFileStatusListener = new MyFileStatusListener();

  setCanYieldUpdate(true);
}
 

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

示例5: highlightTodos

点赞 3

import com.intellij.psi.search.PsiTodoSearchHelper; //导入依赖的package包/类
static void highlightTodos(@Nonnull PsiFile file,
                           @Nonnull CharSequence text,
                           int startOffset,
                           int endOffset,
                           @Nonnull ProgressIndicator progress,
                           @Nonnull ProperTextRange priorityRange,
                           @Nonnull Collection<HighlightInfo> insideResult,
                           @Nonnull Collection<HighlightInfo> outsideResult) {
  PsiTodoSearchHelper helper = PsiTodoSearchHelper.getInstance(file.getProject());
  if (helper == null || !shouldHighlightTodos(helper, file)) return;
  TodoItem[] todoItems = helper.findTodoItems(file, startOffset, endOffset);
  if (todoItems.length == 0) return;

  for (TodoItem todoItem : todoItems) {
    ProgressManager.checkCanceled();
    TextRange range = todoItem.getTextRange();
    TextAttributes attributes = todoItem.getPattern().getAttributes().getTextAttributes();
    HighlightInfo.Builder builder = HighlightInfo.newHighlightInfo(HighlightInfoType.TODO).range(range);
    builder.textAttributes(attributes);
    String description = text.subSequence(range.getStartOffset(), range.getEndOffset()).toString();
    builder.description(description);
    builder.unescapedToolTip(StringUtil.shortenPathWithEllipsis(description, 1024));
    HighlightInfo info = builder.createUnconditionally();
    (priorityRange.containsRange(info.getStartOffset(), info.getEndOffset()) ? insideResult : outsideResult).add(info);
  }
}
 

开发者ID:consulo,
项目名称:consulo,
代码行数:27,
代码来源:GeneralHighlightingPass.java

示例6: getTodoItems

点赞 3

import com.intellij.psi.search.PsiTodoSearchHelper; //导入依赖的package包/类
@Override
protected TodoItemData[] getTodoItems() {
  return ApplicationManager.getApplication().runReadAction(new Computable<TodoItemData[]>() {
    @Override
    public TodoItemData[] compute() {
      final PsiTodoSearchHelper helper = PsiTodoSearchHelper.getInstance(myProject);

      PsiFile psiFile = myFile == null ? null : PsiManager.getInstance(myProject).findFile(myFile);
      if (psiFile != null) {
        return TodoForBaseRevision.convertTodo(helper.findTodoItems(psiFile));
      }

      return TodoForBaseRevision.convertTodo(getTodoForText(helper));
    }
  });
}
 

开发者ID:consulo,
项目名称:consulo,
代码行数:17,
代码来源:TodoForExistingFile.java

示例7: findAllTodos

点赞 3

import com.intellij.psi.search.PsiTodoSearchHelper; //导入依赖的package包/类
public static TodoItem[] findAllTodos(final PsiFile psiFile, final PsiTodoSearchHelper helper) {
  final List<TodoItem> todoItems = new ArrayList<TodoItem>(Arrays.asList(helper.findTodoItems(psiFile)));

  psiFile.accept(new PsiRecursiveElementWalkingVisitor() {
    @Override
    public void visitElement(PsiElement element) {
      if (element instanceof PsiLanguageInjectionHost) {
        InjectedLanguageUtil.enumerate(element, new PsiLanguageInjectionHost.InjectedPsiVisitor() {
          @Override
          public void visit(@Nonnull PsiFile injectedPsi, @Nonnull List<PsiLanguageInjectionHost.Shred> places) {
            if (places.size() == 1) {
              Document document = PsiDocumentManager.getInstance(injectedPsi.getProject()).getCachedDocument(injectedPsi);
              if (!(document instanceof DocumentWindow)) return;
              for (TodoItem item : helper.findTodoItems(injectedPsi)) {
                TextRange rangeInHost = ((DocumentWindow)document).injectedToHost(item.getTextRange());
                todoItems.add(new TodoItemImpl(psiFile, rangeInHost.getStartOffset(), rangeInHost.getEndOffset(), item.getPattern()));
              }
            }
          }
        });
      }
      super.visitElement(element);
    }
  });
  return todoItems.toArray(new TodoItem[todoItems.size()]);
}
 

开发者ID:consulo,
项目名称:consulo,
代码行数:27,
代码来源:TodoFileNode.java

示例8: TodoTreeBuilder

点赞 3

import com.intellij.psi.search.PsiTodoSearchHelper; //导入依赖的package包/类
TodoTreeBuilder(JTree tree, DefaultTreeModel treeModel, Project project) {
  super(tree, treeModel, null, MyComparator.ourInstance, false);
  myProject = project;

  myFileTree = new FileTree();
  myDirtyFileSet = new HashSet<>();

  myFile2Highlighter = new HashMap<>();

  PsiManager psiManager = PsiManager.getInstance(myProject);
  mySearchHelper = PsiTodoSearchHelper.getInstance(myProject);
  psiManager.addPsiTreeChangeListener(new MyPsiTreeChangeListener());

  myFileStatusListener = new MyFileStatusListener();

  setCanYieldUpdate(true);
}
 

开发者ID:consulo,
项目名称:consulo,
代码行数:18,
代码来源:TodoTreeBuilder.java

示例9: accept

点赞 2

import com.intellij.psi.search.PsiTodoSearchHelper; //导入依赖的package包/类
/**
 * @return <code>true</code> if and only if specified <code>psiFile</code> has
 * <code>TodoItem</code>s accepted by the filter.
 */
public boolean accept(PsiTodoSearchHelper searchHelper,PsiFile psiFile){
  for(Iterator<TodoPattern> i=iterator();i.hasNext();){
    TodoPattern todoPattern= i.next();
    if(searchHelper.getTodoItemsCount(psiFile,todoPattern)>0){
      return true;
    }
  }
  return false;
}
 

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

示例10: getTodoItems

点赞 2

import com.intellij.psi.search.PsiTodoSearchHelper; //导入依赖的package包/类
protected TodoItemData[] getTodoItems() {
  return ApplicationManager.getApplication().runReadAction(new Computable<TodoItemData[]>() {
    @Override
    public TodoItemData[] compute() {
      final PsiTodoSearchHelper helper = PsiTodoSearchHelper.SERVICE.getInstance(myProject);

      PsiFile psiFile = myFile == null ? null : PsiManager.getInstance(myProject).findFile(myFile);
      if (psiFile != null) {
        return TodoForBaseRevision.convertTodo(helper.findTodoItems(psiFile));
      }

      return TodoForBaseRevision.convertTodo(getTodoForText(helper));
    }
  });
}
 

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

示例11: getTodoItems

点赞 2

import com.intellij.psi.search.PsiTodoSearchHelper; //导入依赖的package包/类
@Override
protected TodoItemData[] getTodoItems() {
  final TodoItemData[] items = (TodoItemData[])myGetter.get();
  if (items != null) return items;
  final TodoItem[] todoItems = getTodoForText(PsiTodoSearchHelper.SERVICE.getInstance(myProject));
  if (todoItems != null) {
    final TodoItemData[] arr = convertTodo(todoItems);
    mySaver.consume(arr);
    return arr;
  }
  return null;
}
 

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

示例12: getTodoForText

点赞 2

import com.intellij.psi.search.PsiTodoSearchHelper; //导入依赖的package包/类
protected TodoItem[] getTodoForText(PsiTodoSearchHelper helper) {
  final PsiFile psiFile = ApplicationManager.getApplication().runReadAction(new Computable<PsiFile>() {
    @Override
    public PsiFile compute() {
      return PsiFileFactory.getInstance(myProject).createFileFromText((myOldRevision ? "old" : "") + myFileName, myFileType, myText);
    }
  });
  return helper.findTodoItemsLight(psiFile);
}
 

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

示例13: TodoCheckinHandlerWorker

点赞 2

import com.intellij.psi.search.PsiTodoSearchHelper; //导入依赖的package包/类
public TodoCheckinHandlerWorker(final Project project, final Collection<Change> changes, final TodoFilter todoFilter,
                                final boolean includePattern) {
  this.changes = changes;
  myTodoFilter = todoFilter;
  myIncludePattern = includePattern;
  myPsiManager = PsiManager.getInstance(project);
  mySearchHelper = PsiTodoSearchHelper.SERVICE.getInstance(project);
  myAddedOrEditedTodos = new ArrayList<TodoItem>();
  myInChangedTodos = new ArrayList<TodoItem>();
  mySkipped = new SmartList<Pair<FilePath,String>>();
  myEditedFileProcessor = new MyEditedFileProcessor(project, new Acceptor() {
    @Override
    public void skipped(Pair<FilePath, String> pair) {
      mySkipped.add(pair);
    }

    @Override
    public void addedOrEdited(TodoItem todoItem) {
      myAddedOrEditedTodos.add(todoItem);
    }

    @Override
    public void inChanged(TodoItem todoItem) {
      myInChangedTodos.add(todoItem);
    }
  }, myTodoFilter);
}
 

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

示例14: highlightTodos

点赞 2

import com.intellij.psi.search.PsiTodoSearchHelper; //导入依赖的package包/类
private static void highlightTodos(@NotNull PsiFile file,
                                   @NotNull CharSequence text,
                                   int startOffset,
                                   int endOffset,
                                   @NotNull ProgressIndicator progress,
                                   @NotNull ProperTextRange priorityRange,
                                   @NotNull Collection<HighlightInfo> result,
                                   @NotNull Collection<HighlightInfo> outsideResult) {
  PsiTodoSearchHelper helper = PsiTodoSearchHelper.SERVICE.getInstance(file.getProject());
  TodoItem[] todoItems = helper.findTodoItems(file, startOffset, endOffset);
  if (todoItems.length == 0) return;

  for (TodoItem todoItem : todoItems) {
    progress.checkCanceled();
    TextRange range = todoItem.getTextRange();
    String description = text.subSequence(range.getStartOffset(), range.getEndOffset()).toString();
    TextAttributes attributes = todoItem.getPattern().getAttributes().getTextAttributes();
    HighlightInfo.Builder builder = HighlightInfo.newHighlightInfo(HighlightInfoType.TODO).range(range);
    if (attributes != null) {
      builder.textAttributes(attributes);
    }
    builder.descriptionAndTooltip(description);
    HighlightInfo info = builder.createUnconditionally();
    if (priorityRange.containsRange(info.getStartOffset(), info.getEndOffset())) {
      result.add(info);
    }
    else {
      outsideResult.add(info);
    }
  }
}
 

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

示例15: isTodoComment

点赞 2

import com.intellij.psi.search.PsiTodoSearchHelper; //导入依赖的package包/类
public static boolean isTodoComment(PsiComment comment) {
  final PsiFile file = comment.getContainingFile();
  final PsiTodoSearchHelper searchHelper = PsiTodoSearchHelper.SERVICE.getInstance(comment.getProject());
  final TodoItem[] todoItems = searchHelper.findTodoItems(file);
  for (final TodoItem todoItem : todoItems) {
    final TextRange commentTextRange = comment.getTextRange();
    final TextRange todoTextRange = todoItem.getTextRange();
    if (commentTextRange.contains(todoTextRange)) {
      return true;
    }
  }
  return false;
}
 

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

示例16: shouldHighlightTodos

点赞 2

import com.intellij.psi.search.PsiTodoSearchHelper; //导入依赖的package包/类
private static boolean shouldHighlightTodos(PsiTodoSearchHelper helper, PsiFile file) {
  if (helper instanceof PsiTodoSearchHelperImpl) {
    PsiTodoSearchHelperImpl helperImpl = (PsiTodoSearchHelperImpl) helper;
    return helperImpl.shouldHighlightInEditor(file);
  } else {
    return false;
  }
}
 

开发者ID:consulo,
项目名称:consulo,
代码行数:9,
代码来源:GeneralHighlightingPass.java

示例17: getTodoItems

点赞 2

import com.intellij.psi.search.PsiTodoSearchHelper; //导入依赖的package包/类
@Override
protected TodoItemData[] getTodoItems() {
  final TodoItemData[] items = (TodoItemData[])myGetter.get();
  if (items != null) return items;
  final TodoItem[] todoItems = getTodoForText(PsiTodoSearchHelper.getInstance(myProject));
  if (todoItems != null) {
    final TodoItemData[] arr = convertTodo(todoItems);
    mySaver.consume(arr);
    return arr;
  }
  return null;
}
 

开发者ID:consulo,
项目名称:consulo,
代码行数:13,
代码来源:TodoForBaseRevision.java

示例18: TodoCheckinHandlerWorker

点赞 2

import com.intellij.psi.search.PsiTodoSearchHelper; //导入依赖的package包/类
public TodoCheckinHandlerWorker(final Project project, final Collection<Change> changes, final TodoFilter todoFilter,
                                final boolean includePattern) {
  this.changes = changes;
  myTodoFilter = todoFilter;
  myIncludePattern = includePattern;
  myPsiManager = PsiManager.getInstance(project);
  mySearchHelper = PsiTodoSearchHelper.getInstance(project);
  myAddedOrEditedTodos = new ArrayList<TodoItem>();
  myInChangedTodos = new ArrayList<TodoItem>();
  mySkipped = new SmartList<Pair<FilePath,String>>();
  myEditedFileProcessor = new MyEditedFileProcessor(project, new Acceptor() {
    @Override
    public void skipped(Pair<FilePath, String> pair) {
      mySkipped.add(pair);
    }

    @Override
    public void addedOrEdited(TodoItem todoItem) {
      myAddedOrEditedTodos.add(todoItem);
    }

    @Override
    public void inChanged(TodoItem todoItem) {
      myInChangedTodos.add(todoItem);
    }
  }, myTodoFilter);
}
 

开发者ID:consulo,
项目名称:consulo,
代码行数:28,
代码来源:TodoCheckinHandlerWorker.java

示例19: TodoTreeStructure

点赞 2

import com.intellij.psi.search.PsiTodoSearchHelper; //导入依赖的package包/类
@RequiredReadAction
public TodoTreeStructure(Project project) {
  super(project);
  myArePackagesShown = PsiPackageSupportProviders.isPackageSupported(project);
  mySummaryElement = new ToDoSummary();
  mySearchHelper = PsiTodoSearchHelper.getInstance(project);
}
 

开发者ID:consulo,
项目名称:consulo,
代码行数:8,
代码来源:TodoTreeStructure.java

示例20: isTodoComment

点赞 2

import com.intellij.psi.search.PsiTodoSearchHelper; //导入依赖的package包/类
public static boolean isTodoComment(PsiComment comment) {
  final PsiFile file = comment.getContainingFile();
  final PsiTodoSearchHelper searchHelper = PsiTodoSearchHelper.getInstance(comment.getProject());
  final TodoItem[] todoItems = searchHelper.findTodoItems(file);
  for (final TodoItem todoItem : todoItems) {
    final TextRange commentTextRange = comment.getTextRange();
    final TextRange todoTextRange = todoItem.getTextRange();
    if (commentTextRange.contains(todoTextRange)) {
      return true;
    }
  }
  return false;
}
 

开发者ID:consulo,
项目名称:consulo-java
代码行数:14,
代码来源:TodoUtil.java

示例21: CustomChangelistTodoTreeStructure

点赞 2

import com.intellij.psi.search.PsiTodoSearchHelper; //导入依赖的package包/类
public CustomChangelistTodoTreeStructure(Project project, PsiTodoSearchHelper searchHelper) {
  super(project);
  mySearchHelper = searchHelper;
}
 

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

示例22: getSearchHelper

点赞 2

import com.intellij.psi.search.PsiTodoSearchHelper; //导入依赖的package包/类
@Override
public PsiTodoSearchHelper getSearchHelper() {
  return mySearchHelper;
}
 

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

示例23: TodoTreeStructure

点赞 2

import com.intellij.psi.search.PsiTodoSearchHelper; //导入依赖的package包/类
public TodoTreeStructure(Project project){
  super(project);
  myArePackagesShown=true;
  mySummaryElement=new ToDoSummary();
  mySearchHelper= PsiTodoSearchHelper.SERVICE.getInstance(project);
}
 

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

示例24: getSearchHelper

点赞 2

import com.intellij.psi.search.PsiTodoSearchHelper; //导入依赖的package包/类
public PsiTodoSearchHelper getSearchHelper() {
  return mySearchHelper;
}
 

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

示例25: projectOpened

点赞 2

import com.intellij.psi.search.PsiTodoSearchHelper; //导入依赖的package包/类
public void projectOpened() {
    TimerEventsSourceAppComponent timerEventsSource = ApplicationManager.getApplication().getComponent(TimerEventsSourceAppComponent.class);
    listener = new TimerEventsSourceAppComponent.Listener() {
        @Override
        public void onTimerEvent() {
            if (!status.equals(PomodoroStatus.IDLE)) {
                remainingSeconds--;
                if (remainingSeconds <= 0) {
                    switch (status) {
                        case RESTING:
                            remainingSeconds = POMODORO_LENGTH;
                            status = PomodoroStatus.IDLE;
                            //TODO show message
                            break;
                        case RUNNING:
                            remainingSeconds = REST_LENGTH;
                            status = PomodoroStatus.RESTING;
                            //TODO increase todo pomodoro # in comment, and remove *
                            break;
                    }
                }
                System.out.println(status + " " + formatTime(remainingSeconds));
            }
        }
    };
    timerEventsSource.addListener(listener);


    VirtualFileManager.getInstance().addVirtualFileListener(new VirtualFileAdapter() {
        @Override
        public void contentsChanged(VirtualFileEvent event) {
            PsiTodoSearchHelper todoHelper = PsiTodoSearchHelper.SERVICE.getInstance(myProject);
            PsiFile psiFile = PsiManager.getInstance(myProject).findFile(event.getFile());

            TodoItem[] todoItems = getTodoItems(todoHelper, psiFile);
            String activePomodoroText = extractTodoTextOnly(getTodoItemText(activeTodoItem));
            for (TodoItem todoItem : todoItems) {
                String todoText = getTodoItemText(todoItem);
                String pomodoroText = extractTodoTextOnly(todoText);
                if (matchActivePattern(todoText)) {
                    if (!pomodoroText.equals(activePomodoroText)) {
                        setActivePomodoro(todoItem, myProject);
                    }
                    break;
                } else {
                    if (matchInactivePattern(todoText) && pomodoroText.equals(activePomodoroText)) {
                        setInactivePomodoro(todoText, myProject);
                    }
                }

            }
        }
    }, myProject);
}
 

开发者ID:rilopez,
项目名称:pomodoro-todo-comments,
代码行数:55,
代码来源:PomodoroCommentVSFListener.java

示例26: getTodoItems

点赞 2

import com.intellij.psi.search.PsiTodoSearchHelper; //导入依赖的package包/类
private TodoItem[] getTodoItems(PsiTodoSearchHelper todoHelper, PsiFile psiFile) {
    return todoHelper.findTodoItems(psiFile);
}
 

开发者ID:rilopez,
项目名称:pomodoro-todo-comments,
代码行数:4,
代码来源:PomodoroCommentVSFListener.java


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