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


Java ReadWriteAccessDetector.isDeclarationWriteAccess方法代码示例

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


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

示例1: getHighlightUsages

import com.intellij.codeInsight.highlighting.ReadWriteAccessDetector; //导入方法依赖的package包/类
/**
 * Returns read and write usages of psi element inside a single element
 *
 * @param target target psi element
 * @param psiElement psi element to search in
 * @return a pair where first element is read usages and second is write usages
 */
public static Couple<Collection<TextRange>> getHighlightUsages(@NotNull PsiElement target, PsiElement psiElement, boolean withDeclarations) {
  Collection<TextRange> readRanges = new ArrayList<TextRange>();
  Collection<TextRange> writeRanges = new ArrayList<TextRange>();
  final ReadWriteAccessDetector detector = ReadWriteAccessDetector.findDetector(target);
  final FindUsagesManager findUsagesManager = ((FindManagerImpl)FindManager.getInstance(target.getProject())).getFindUsagesManager();
  final FindUsagesHandler findUsagesHandler = findUsagesManager.getFindUsagesHandler(target, true);
  final LocalSearchScope scope = new LocalSearchScope(psiElement);
  Collection<PsiReference> refs = findUsagesHandler != null
                            ? findUsagesHandler.findReferencesToHighlight(target, scope)
                            : ReferencesSearch.search(target, scope).findAll();
  for (PsiReference psiReference : refs) {
    if (psiReference == null) {
      LOG.error("Null reference returned, findUsagesHandler=" + findUsagesHandler + "; target=" + target + " of " + target.getClass());
      continue;
    }
    final List<TextRange> textRanges = HighlightUsagesHandler.getRangesToHighlight(psiReference);
    if (detector == null || detector.getReferenceAccess(target, psiReference) == ReadWriteAccessDetector.Access.Read) {
      readRanges.addAll(textRanges);
    }
    else {
      writeRanges.addAll(textRanges);
    }
  }

  if (withDeclarations) {
    final TextRange declRange = HighlightUsagesHandler.getNameIdentifierRange(psiElement.getContainingFile(), target);
    if (declRange != null) {
      if (detector != null && detector.isDeclarationWriteAccess(target)) {
        writeRanges.add(declRange);
      }
      else {
        readRanges.add(declRange);
      }
    }
  }

  return Couple.of(readRanges, writeRanges);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:46,代码来源:IdentifierHighlighterPass.java

示例2: highlightTargetUsages

import com.intellij.codeInsight.highlighting.ReadWriteAccessDetector; //导入方法依赖的package包/类
private void highlightTargetUsages(@NotNull PsiElement target) {
  final ReadWriteAccessDetector detector = ReadWriteAccessDetector.findDetector(target);
  final FindUsagesManager findUsagesManager = ((FindManagerImpl)FindManager.getInstance(target.getProject())).getFindUsagesManager();
  final FindUsagesHandler findUsagesHandler = findUsagesManager.getFindUsagesHandler(target, true);
  final LocalSearchScope scope = new LocalSearchScope(myFile);
  Collection<PsiReference> refs = findUsagesHandler != null
                            ? findUsagesHandler.findReferencesToHighlight(target, scope)
                            : ReferencesSearch.search(target, scope).findAll();
  for (PsiReference psiReference : refs) {
    final List<TextRange> textRanges = HighlightUsagesHandler.getRangesToHighlight(psiReference);
    if (detector == null || detector.getReferenceAccess(target, psiReference) == ReadWriteAccessDetector.Access.Read) {
      myReadAccessRanges.addAll(textRanges);
    }
    else {
      myWriteAccessRanges.addAll(textRanges);
    }
  }

  final TextRange declRange = HighlightUsagesHandler.getNameIdentifierRange(myFile, target);
  if (declRange != null) {
    if (detector != null && detector.isDeclarationWriteAccess(target)) {
      myWriteAccessRanges.add(declRange);
    }
    else {
      myReadAccessRanges.add(declRange);
    }
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:29,代码来源:IdentifierHighlighterPass.java

示例3: getUsages

import com.intellij.codeInsight.highlighting.ReadWriteAccessDetector; //导入方法依赖的package包/类
@Nonnull
private static Couple<Collection<TextRange>> getUsages(@Nonnull PsiElement target, PsiElement psiElement, boolean withDeclarations, boolean detectAccess) {
  List<TextRange> readRanges = new ArrayList<>();
  List<TextRange> writeRanges = new ArrayList<>();
  final ReadWriteAccessDetector detector = detectAccess ? ReadWriteAccessDetector.findDetector(target) : null;
  final FindUsagesManager findUsagesManager = ((FindManagerImpl)FindManager.getInstance(target.getProject())).getFindUsagesManager();
  final FindUsagesHandler findUsagesHandler = findUsagesManager.getFindUsagesHandler(target, true);
  final LocalSearchScope scope = new LocalSearchScope(psiElement);
  Collection<PsiReference> refs = findUsagesHandler != null
                                  ? findUsagesHandler.findReferencesToHighlight(target, scope)
                                  : ReferencesSearch.search(target, scope).findAll();
  for (PsiReference psiReference : refs) {
    if (psiReference == null) {
      LOG.error("Null reference returned, findUsagesHandler=" + findUsagesHandler + "; target=" + target + " of " + target.getClass());
      continue;
    }
    List<TextRange> destination;
    if (detector == null || detector.getReferenceAccess(target, psiReference) == ReadWriteAccessDetector.Access.Read) {
      destination = readRanges;
    }
    else {
      destination = writeRanges;
    }
    HighlightUsagesHandler.collectRangesToHighlight(psiReference, destination);
  }

  if (withDeclarations) {
    final TextRange declRange = HighlightUsagesHandler.getNameIdentifierRange(psiElement.getContainingFile(), target);
    if (declRange != null) {
      if (detector != null && detector.isDeclarationWriteAccess(target)) {
        writeRanges.add(declRange);
      }
      else {
        readRanges.add(declRange);
      }
    }
  }

  return Couple.<Collection<TextRange>>of(readRanges, writeRanges);
}
 
开发者ID:consulo,项目名称:consulo,代码行数:41,代码来源:IdentifierHighlighterPass.java

示例4: getUsages

import com.intellij.codeInsight.highlighting.ReadWriteAccessDetector; //导入方法依赖的package包/类
@NotNull
private static Couple<List<TextRange>> getUsages(@NotNull PsiElement target,
        @NotNull PsiElement psiElement) {
    List<TextRange> readRanges = new ArrayList<>();
    List<TextRange> writeRanges = new ArrayList<>();
    final ReadWriteAccessDetector detector = ReadWriteAccessDetector.findDetector(target);
    final FindUsagesManager findUsagesManager = ((FindManagerImpl) FindManager.getInstance(
            target.getProject())).getFindUsagesManager();
    final FindUsagesHandler findUsagesHandler =
            findUsagesManager.getFindUsagesHandler(target, true);
    final LocalSearchScope scope = new LocalSearchScope(psiElement);
    Collection<PsiReference> refs =
            findUsagesHandler != null ? findUsagesHandler.findReferencesToHighlight(target,
                    scope) : ReferencesSearch.search(target, scope).findAll();
    for (PsiReference psiReference : refs) {
        if (psiReference == null) {
            Log.error("Null reference returned, findUsagesHandler=" + findUsagesHandler
                    + "; target=" + target + " of " + target.getClass());
            continue;
        }
        List<TextRange> destination;
        if (detector == null || detector.getReferenceAccess(target, psiReference)
                == ReadWriteAccessDetector.Access.Read) {
            destination = readRanges;
        } else {
            destination = writeRanges;
        }
        HighlightUsagesHandler.collectRangesToHighlight(psiReference, destination);
    }
    
    final TextRange declareRange =
            HighlightUsagesHandler.getNameIdentifierRange(psiElement.getContainingFile(),
                    target);
    if (declareRange != null) {
        if (detector != null && detector.isDeclarationWriteAccess(target)) {
            writeRanges.add(declareRange);
        } else {
            readRanges.add(declareRange);
        }
    }
    
    return Couple.of(readRanges, writeRanges);
}
 
开发者ID:huoguangjin,项目名称:MultiHighlight,代码行数:44,代码来源:MultiHighlightHandler.java


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