• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ReadWriteAccessDetector类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: convert

import com.intellij.codeInsight.highlighting.ReadWriteAccessDetector; //导入依赖的package包/类
@NotNull
public static Usage convert(@NotNull PsiElement[] primaryElements, @NotNull UsageInfo usageInfo) {
  PsiElement usageElement = usageInfo.getElement();
  for(ReadWriteAccessDetector detector: Extensions.getExtensions(ReadWriteAccessDetector.EP_NAME)) {
    if (isReadWriteAccessibleElements(primaryElements, detector)) {
      final ReadWriteAccessDetector.Access rwAccess = detector.getExpressionAccess(usageElement);
      return new ReadWriteAccessUsageInfo2UsageAdapter(usageInfo,
                                                       rwAccess != ReadWriteAccessDetector.Access.Write,
                                                       rwAccess != ReadWriteAccessDetector.Access.Read);
    }
  }
  return new UsageInfo2UsageAdapter(usageInfo);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:UsageInfoToUsageConverter.java


示例2: isReadWriteAccessibleElements

import com.intellij.codeInsight.highlighting.ReadWriteAccessDetector; //导入依赖的package包/类
private static boolean isReadWriteAccessibleElements(@NotNull PsiElement[] elements, @NotNull ReadWriteAccessDetector detector) {
  if (elements.length == 0) {
    return false;
  }
  for (PsiElement element : elements) {
    if (!detector.isReadWriteAccessible(element)) return false;
  }
  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:UsageInfoToUsageConverter.java


示例3: 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


示例4: convert

import com.intellij.codeInsight.highlighting.ReadWriteAccessDetector; //导入依赖的package包/类
@NotNull
public static Usage convert(@NotNull TargetElementsDescriptor descriptor, @NotNull UsageInfo usageInfo) {
  PsiElement[] primaryElements = descriptor.getPrimaryElements();

  PsiElement usageElement = usageInfo.getElement();
  for(ReadWriteAccessDetector detector: Extensions.getExtensions(ReadWriteAccessDetector.EP_NAME)) {
    if (isReadWriteAccessibleElements(primaryElements, detector)) {
      final ReadWriteAccessDetector.Access rwAccess = detector.getExpressionAccess(usageElement);
      return new ReadWriteAccessUsageInfo2UsageAdapter(usageInfo,
                                                       rwAccess != ReadWriteAccessDetector.Access.Write,
                                                       rwAccess != ReadWriteAccessDetector.Access.Read);
    }
  }
  return new UsageInfo2UsageAdapter(usageInfo);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:16,代码来源:UsageInfoToUsageConverter.java


示例5: 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


示例6: convert

import com.intellij.codeInsight.highlighting.ReadWriteAccessDetector; //导入依赖的package包/类
@Nonnull
public static Usage convert(@Nonnull PsiElement[] primaryElements, @Nonnull UsageInfo usageInfo) {
  PsiElement usageElement = usageInfo.getElement();
  for(ReadWriteAccessDetector detector: Extensions.getExtensions(ReadWriteAccessDetector.EP_NAME)) {
    if (isReadWriteAccessibleElements(primaryElements, detector)) {
      final ReadWriteAccessDetector.Access rwAccess = detector.getExpressionAccess(usageElement);
      return new ReadWriteAccessUsageInfo2UsageAdapter(usageInfo,
                                                       rwAccess != ReadWriteAccessDetector.Access.Write,
                                                       rwAccess != ReadWriteAccessDetector.Access.Read);
    }
  }
  return new UsageInfo2UsageAdapter(usageInfo);
}
 
开发者ID:consulo,项目名称:consulo,代码行数:14,代码来源:UsageInfoToUsageConverter.java


示例7: isReadWriteAccessibleElements

import com.intellij.codeInsight.highlighting.ReadWriteAccessDetector; //导入依赖的package包/类
private static boolean isReadWriteAccessibleElements(@Nonnull PsiElement[] elements, @Nonnull ReadWriteAccessDetector detector) {
  if (elements.length == 0) {
    return false;
  }
  for (PsiElement element : elements) {
    if (!detector.isReadWriteAccessible(element)) return false;
  }
  return true;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:10,代码来源:UsageInfoToUsageConverter.java


示例8: 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


示例9: 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


示例10: actionPerformed

import com.intellij.codeInsight.highlighting.ReadWriteAccessDetector; //导入依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) {
  final UsageViewPresentation presentation = new UsageViewPresentation();
  final String codeUsagesString = "Conflicts";
  presentation.setCodeUsagesString(codeUsagesString);
  presentation.setTabName(codeUsagesString);
  presentation.setTabText(codeUsagesString);
  presentation.setShowCancelButton(true);

  final ArrayList<Usage> usages = new ArrayList<Usage>(myElementConflictDescription.values().size());
  for (final PsiElement element : myElementConflictDescription.keySet()) {
    if (element == null) {
      usages.add(new DescriptionOnlyUsage());
      continue;
    }
    boolean isRead = false;
    boolean isWrite = false;
    for (ReadWriteAccessDetector detector : Extensions.getExtensions(ReadWriteAccessDetector.EP_NAME)) {
      if (detector.isReadWriteAccessible(element)) {
        final ReadWriteAccessDetector.Access access = detector.getExpressionAccess(element);
        isRead = access != ReadWriteAccessDetector.Access.Write;
        isWrite = access != ReadWriteAccessDetector.Access.Read;
        break;
      }
    }

    for (final String conflictDescription : myElementConflictDescription.get(element)) {
      final UsagePresentation usagePresentation = new DescriptionOnlyUsage(conflictDescription).getPresentation();
      Usage usage = isRead || isWrite ? new ReadWriteAccessUsageInfo2UsageAdapter(new UsageInfo(element), isRead, isWrite) {
        @NotNull
        @Override
        public UsagePresentation getPresentation() {
          return usagePresentation;
        }
      } : new UsageInfo2UsageAdapter(new UsageInfo(element)) {
        @NotNull
        @Override
        public UsagePresentation getPresentation() {
          return usagePresentation;
        }
      };
      usages.add(usage);
    }
  }
  final UsageView usageView = UsageViewManager.getInstance(myProject)
    .showUsages(UsageTarget.EMPTY_ARRAY, usages.toArray(new Usage[usages.size()]), presentation);
  Runnable doRefactoringRunnable = getDoRefactoringRunnable(usageView);
  if (doRefactoringRunnable != null) {
    usageView.addPerformOperationAction(
      doRefactoringRunnable,
      myCommandName != null ? myCommandName : RefactoringBundle.message("retry.command"), 
      "Unable to perform refactoring. There were changes in code after the usages have been found.", RefactoringBundle.message("usageView.doAction"));
  }
  close(SHOW_CONFLICTS_EXIT_CODE);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:56,代码来源:ConflictsDialog.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java KillApplicationRequestPBImpl类代码示例发布时间:2022-05-22
下一篇:
Java DefaultIntroductionAdvisor类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap