Java 类com.intellij.util.codeInsight.CommentUtilCore 实例源码

项目:intellij-ce-playground    文件:PsiSearchHelperImpl.java   
@Override
public boolean processCommentsContainingIdentifier(@NotNull String identifier,
                                                   @NotNull SearchScope searchScope,
                                                   @NotNull final Processor<PsiElement> processor) {
  TextOccurenceProcessor occurrenceProcessor = new TextOccurenceProcessor() {
    @Override
    public boolean execute(@NotNull PsiElement element, int offsetInElement) {
      if (CommentUtilCore.isCommentTextElement(element)) {
        if (element.findReferenceAt(offsetInElement) == null) {
          return processor.process(element);
        }
      }
      return true;
    }
  };
  return processElementsWithWord(occurrenceProcessor, searchScope, identifier, UsageSearchContext.IN_COMMENTS, true);
}
项目:tools-idea    文件:PsiSearchHelperImpl.java   
@Override
public boolean processCommentsContainingIdentifier(@NotNull String identifier,
                                                   @NotNull SearchScope searchScope,
                                                   @NotNull final Processor<PsiElement> processor) {
  TextOccurenceProcessor occurrenceProcessor = new TextOccurenceProcessor() {
    @Override
    public boolean execute(PsiElement element, int offsetInElement) {
      if (CommentUtilCore.isCommentTextElement(element)) {
        if (element.findReferenceAt(offsetInElement) == null) {
          return processor.process(element);
        }
      }
      return true;
    }
  };
  return processElementsWithWord(occurrenceProcessor, searchScope, identifier, UsageSearchContext.IN_COMMENTS, true);
}
项目:consulo    文件:PlatformIdTableBuilding.java   
private boolean isCommentToken(Map<Language, LanguageVersion> cache, IElementType token) {
  Language language = token.getLanguage();
  LanguageVersion languageVersion = cache.get(language);
  if (languageVersion == null) {
    cache.put(language, languageVersion = LanguageVersionUtil.findLanguageVersion(language, myProject, myFile));
  }
  return CommentUtilCore.isCommentToken(token, languageVersion);
}
项目:consulo    文件:PsiSearchHelperImpl.java   
@Override
public boolean processCommentsContainingIdentifier(@Nonnull String identifier,
                                                   @Nonnull SearchScope searchScope,
                                                   @Nonnull final Processor<PsiElement> processor) {
  TextOccurenceProcessor occurrenceProcessor = (element, offsetInElement) -> {
    if (CommentUtilCore.isCommentTextElement(element) && element.findReferenceAt(offsetInElement) == null) {
      return processor.process(element);
    }
    return true;
  };
  return processElementsWithWord(occurrenceProcessor, searchScope, identifier, UsageSearchContext.IN_COMMENTS, true);
}
项目:consulo    文件:CodeEditUtil.java   
public static ASTNode addChildren(ASTNode parent, @Nonnull ASTNode first, @Nonnull ASTNode last, ASTNode anchorBefore) {
  ASTNode lastChild = last.getTreeNext();
  ASTNode current = first;
  while (current != lastChild) {
    saveWhitespacesInfo(current);
    checkForOuters(current);
    current = current.getTreeNext();
  }

  if (anchorBefore != null && CommentUtilCore.isComment(anchorBefore)) {
    final ASTNode anchorPrev = anchorBefore.getTreePrev();
    if (anchorPrev != null && anchorPrev.getElementType() == TokenType.WHITE_SPACE) {
      anchorBefore = anchorPrev;
    }
  }

  parent.addChildren(first, lastChild, anchorBefore);
  ASTNode firstAddedLeaf = findFirstLeaf(first, last);
  ASTNode prevLeaf = TreeUtil.prevLeaf(first);
  ASTNode result = first;
  if (firstAddedLeaf != null) {
    ASTNode placeHolderEnd = makePlaceHolderBetweenTokens(prevLeaf, firstAddedLeaf, isFormattingRequired(prevLeaf, first), false);
    if (placeHolderEnd != prevLeaf && first == firstAddedLeaf) {
      result = placeHolderEnd;
    }
    ASTNode lastAddedLeaf = findLastLeaf(first, last);
    placeHolderEnd = makePlaceHolderBetweenTokens(lastAddedLeaf, TreeUtil.nextLeaf(last), true, false);
    if (placeHolderEnd != lastAddedLeaf && lastAddedLeaf == first) {
      result = placeHolderEnd;
    }
  }
  else {
    makePlaceHolderBetweenTokens(prevLeaf, TreeUtil.nextLeaf(last), isFormattingRequired(prevLeaf, first), false);
  }
  return result;
}
项目:consulo-xml    文件:XHtmlFilterLexer.java   
public void advance() {
  final IElementType tokenType = myDelegate.getTokenType();

  if (tokenType == XmlElementType.XML_COMMENT_CHARACTERS) {
    scanWordsInToken(UsageSearchContext.IN_COMMENTS, false, false);
    advanceTodoItemCountsInToken();
  } else if (tokenType == XmlElementType.XML_ATTRIBUTE_VALUE_TOKEN ||
      tokenType == XmlElementType.XML_NAME ||
      tokenType == XmlElementType.XML_TAG_NAME
     ) {
    scanWordsInToken(UsageSearchContext.IN_PLAIN_TEXT | UsageSearchContext.IN_FOREIGN_LANGUAGES, tokenType == XmlElementType.XML_ATTRIBUTE_VALUE_TOKEN,
                     false);
  } else if (tokenType.getLanguage() != XMLLanguage.INSTANCE &&
    tokenType.getLanguage() != Language.ANY         
  ) {
    boolean inComments = CommentUtilCore.isCommentToken(tokenType, LanguageVersionUtil.findDefaultVersion(tokenType.getLanguage()));
    scanWordsInToken((inComments)?UsageSearchContext.IN_COMMENTS:UsageSearchContext.IN_PLAIN_TEXT | UsageSearchContext.IN_FOREIGN_LANGUAGES, true,
                     false);

    if (inComments) advanceTodoItemCountsInToken();
  }
  else if (!XmlFilterLexer.ourNoWordsTokenSet.contains(tokenType)) {
    scanWordsInToken(UsageSearchContext.IN_PLAIN_TEXT, false, false);
  }

  myDelegate.advance();
}