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


Java SliceUsage类代码示例

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


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

示例1: dotest

import com.intellij.slicer.SliceUsage; //导入依赖的package包/类
private void dotest() throws Exception {
  configureByFile("/codeInsight/slice/backward/"+getTestName(false)+".java");
  Map<String, RangeMarker> sliceUsageName2Offset = extractSliceOffsetsFromDocument(getEditor().getDocument());
  PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
  PsiElement element = new SliceHandler(true).getExpressionAtCaret(getEditor(), getFile());
  assertNotNull(element);
  calcRealOffsets(element, sliceUsageName2Offset, myFlownOffsets);
  Collection<HighlightInfo> errors = highlightErrors();
  assertEmpty(errors);
  SliceAnalysisParams params = new SliceAnalysisParams();
  params.scope = new AnalysisScope(getProject());
  params.dataFlowToThis = true;

  SliceUsage usage = SliceManager.createRootUsage(element, params);
  checkUsages(usage, true, myFlownOffsets);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:17,代码来源:SliceBackwardTest.java

示例2: processValuesFlownTo

import com.intellij.slicer.SliceUsage; //导入依赖的package包/类
private static boolean processValuesFlownTo(@NotNull final PsiExpression argument, @NotNull PsiElement scope, @NotNull PsiManager manager, @NotNull final Processor<PsiExpression> processor)
{
	SliceAnalysisParams params = new SliceAnalysisParams();
	params.dataFlowToThis = true;
	params.scope = new AnalysisScope(new LocalSearchScope(scope), manager.getProject());

	SliceRootNode rootNode = new SliceRootNode(manager.getProject(), new DuplicateMap(), SliceUsage.createRootUsage(argument, params));

	Collection<? extends AbstractTreeNode> children = rootNode.getChildren().iterator().next().getChildren();
	for(AbstractTreeNode child : children)
	{
		SliceUsage usage = (SliceUsage) child.getValue();
		PsiElement element = usage.getElement();
		if(element instanceof PsiExpression && !processor.process((PsiExpression) element))
		{
			return false;
		}
	}

	return !children.isEmpty();
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:22,代码来源:MagicConstantInspection.java

示例3: dotest

import com.intellij.slicer.SliceUsage; //导入依赖的package包/类
private void dotest() throws Exception {
  configureByFile("/codeInsight/slice/backward/"+getTestName(false)+".java");
  Map<String, RangeMarker> sliceUsageName2Offset = extractSliceOffsetsFromDocument(getEditor().getDocument());
  PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
  PsiElement element = new SliceHandler(true).getExpressionAtCaret(getEditor(), getFile());
  assertNotNull(element);
  calcRealOffsets(element, sliceUsageName2Offset, myFlownOffsets);
  Collection<HighlightInfo> errors = highlightErrors();
  assertEmpty(errors);
  SliceAnalysisParams params = new SliceAnalysisParams();
  params.scope = new AnalysisScope(getProject());
  params.dataFlowToThis = true;

  SliceUsage usage = SliceUsage.createRootUsage(element, params);
  checkUsages(usage, true, myFlownOffsets);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:17,代码来源:SliceBackwardTest.java

示例4: checkUsages

import com.intellij.slicer.SliceUsage; //导入依赖的package包/类
private void checkUsages(SliceUsage sliceUsage, ArrayList<SliceUsage> sliceUsages) {
    List<SliceUsage> usageList = new ArrayList<SliceUsage>();
    sliceUsage.processChildren(new CommonProcessors.CollectProcessor<SliceUsage>(usageList));
    for (SliceUsage child : usageList) {
        checkUsages(child, sliceUsages);
    }
    sliceUsages.addAll(usageList);
}
 
开发者ID:erikzielke,项目名称:butterknife_inspections,代码行数:9,代码来源:ButterKnifeNoViewWithIdInspection.java

示例5: dotest

import com.intellij.slicer.SliceUsage; //导入依赖的package包/类
private void dotest() throws Exception {
  configureByFile("/codeInsight/slice/forward/"+getTestName(false)+".java");
  Map<String, RangeMarker> sliceUsageName2Offset = SliceBackwardTest.extractSliceOffsetsFromDocument(getEditor().getDocument());
  PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
  PsiElement element = new SliceForwardHandler().getExpressionAtCaret(getEditor(), getFile());
  assertNotNull(element);
  SliceBackwardTest.calcRealOffsets(element, sliceUsageName2Offset, myFlownOffsets);
  Collection<HighlightInfo> errors = highlightErrors();
  assertEmpty(errors);
  SliceAnalysisParams params = new SliceAnalysisParams();
  params.scope = new AnalysisScope(getProject());
  params.dataFlowToThis = false;
  SliceUsage usage = SliceManager.createRootUsage(element, params);
  SliceBackwardTest.checkUsages(usage, false, myFlownOffsets);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:16,代码来源:SliceForwardTest.java

示例6: checkUsages

import com.intellij.slicer.SliceUsage; //导入依赖的package包/类
static void checkUsages(final SliceUsage usage, final boolean dataFlowToThis, final TIntObjectHashMap<IntArrayList> flownOffsets) {
  final List<SliceUsage> children = new ArrayList<SliceUsage>();
  boolean b = ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() {
    @Override
    public void run() {
      usage.processChildren(new CommonProcessors.CollectProcessor<SliceUsage>(children));
    }
  }, "Expanding", true, usage.getElement().getProject());
  assertTrue(b);
  int startOffset = usage.getElement().getTextOffset();
  IntArrayList list = flownOffsets.get(startOffset);
  int[] offsets = list == null ? new int[0] : list.toArray();
  Arrays.sort(offsets);

  int size = list == null ? 0 : list.size();
  assertEquals(message(startOffset, usage), size, children.size());
  Collections.sort(children, new Comparator<SliceUsage>() {
    @Override
    public int compare(SliceUsage o1, SliceUsage o2) {
      return o1.compareTo(o2);
    }
  });

  for (int i = 0; i < children.size(); i++) {
    SliceUsage child = children.get(i);
    int offset = offsets[i];
    assertEquals(message(offset, child), offset, child.getUsageInfo().getElement().getTextOffset());

    checkUsages(child, dataFlowToThis, flownOffsets);
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:32,代码来源:SliceBackwardTest.java

示例7: message

import com.intellij.slicer.SliceUsage; //导入依赖的package包/类
private static String message(int startOffset, SliceUsage usage) {
  PsiFile file = usage.getElement().getContainingFile();
  Document document = PsiDocumentManager.getInstance(file.getProject()).getDocument(file);
  Editor editor = FileEditorManager.getInstance(file.getProject()).getSelectedTextEditor();
  LogicalPosition position = editor.offsetToLogicalPosition(startOffset);
  return position + ": '" + StringUtil.first(file.getText().substring(startOffset), 100, true) + "'";
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:8,代码来源:SliceBackwardTest.java

示例8: dotest

import com.intellij.slicer.SliceUsage; //导入依赖的package包/类
private void dotest() throws Exception {
  configureByFile("/codeInsight/slice/forward/"+getTestName(false)+".java");
  Map<String, RangeMarker> sliceUsageName2Offset = SliceBackwardTest.extractSliceOffsetsFromDocument(getEditor().getDocument());
  PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
  PsiElement element = new SliceForwardHandler().getExpressionAtCaret(getEditor(), getFile());
  assertNotNull(element);
  SliceBackwardTest.calcRealOffsets(element, sliceUsageName2Offset, myFlownOffsets);
  Collection<HighlightInfo> errors = highlightErrors();
  assertEmpty(errors);
  SliceAnalysisParams params = new SliceAnalysisParams();
  params.scope = new AnalysisScope(getProject());
  params.dataFlowToThis = false;
  SliceUsage usage = SliceUsage.createRootUsage(element, params);
  SliceBackwardTest.checkUsages(usage, false, myFlownOffsets);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:16,代码来源:SliceForwardTest.java

示例9: getFileFromViewHolderInject

import com.intellij.slicer.SliceUsage; //导入依赖的package包/类
private PsiReferenceExpression getFileFromViewHolderInject(PsiExpression psiExpression) {
    SliceAnalysisParams sliceAnalysisParams = new SliceAnalysisParams();
    sliceAnalysisParams.scope = new AnalysisScope(psiExpression.getProject());
    sliceAnalysisParams.dataFlowToThis = true;
    SliceUsage sliceUsage = SliceUsage.createRootUsage(psiExpression, sliceAnalysisParams);
    ArrayList<SliceUsage> children = new ArrayList<SliceUsage>();
    checkUsages(sliceUsage, children);
    for (SliceUsage child : children) {
        if (child.getElement() instanceof PsiLocalVariable) {
            PsiLocalVariable localVariable = (PsiLocalVariable) child.getElement();
            Collection<PsiReference> search = ReferencesSearch.search(localVariable).findAll();
            for (PsiReference psiReference : search) {
                if (psiReference instanceof CompositeElement) {
                    CompositeElement treeParent = ((PsiReferenceExpressionImpl) psiReference).getTreeParent();
                    if (treeParent instanceof PsiAssignmentExpression) {
                        PsiAssignmentExpression assignmentExpression = (PsiAssignmentExpression) treeParent;
                        PsiExpression rExpression = assignmentExpression.getRExpression();
                        if (rExpression instanceof PsiMethodCallExpression) {
                            PsiMethodCallExpression expression = (PsiMethodCallExpression) rExpression;
                            PsiReferenceExpression methodExpression = expression.getMethodExpression();
                            if (methodExpression.getQualifierExpression() != null) {
                                PsiType type = methodExpression.getQualifierExpression().getType();
                                if (type != null) {
                                    if (type.getCanonicalText().equals("android.view.LayoutInflater")) {
                                        if ("inflate".equals(methodExpression.getReferenceName())) {
                                            PsiExpressionList argumentList = expression.getArgumentList();
                                            PsiExpression layoutFile = argumentList.getExpressions()[0];
                                            if (layoutFile instanceof PsiReferenceExpression) {
                                                return (PsiReferenceExpression) layoutFile;
                                            }
                                        }
                                    }
                                }
                            }

                        }
                    }
                }
            }
        }
    }
    return null;
}
 
开发者ID:erikzielke,项目名称:butterknife_inspections,代码行数:44,代码来源:ButterKnifeNoViewWithIdInspection.java

示例10: createPanel

import com.intellij.slicer.SliceUsage; //导入依赖的package包/类
@NotNull
protected JComponent createPanel(@NotNull PsiElement element, final boolean dataFlowToThis)
{
	ToolWindow toolWindow = ToolWindowManager.getInstance(myProject).getToolWindow(ToolWindowId.FIND);
	SliceAnalysisParams params = createParams(element, dataFlowToThis);

	SliceRootNode rootNode = new SliceRootNode(myProject, new DuplicateMap(), SliceUsage.createRootUsage(element, params));

	return new SlicePanel(myProject, dataFlowToThis, rootNode, false, toolWindow)
	{
		@Override
		public boolean isToShowAutoScrollButton()
		{
			return false;
		}

		@Override
		public boolean isToShowPreviewButton()
		{
			return false;
		}

		@Override
		public boolean isToShowCloseButton()
		{
			return false;
		}

		@Override
		public boolean isAutoScroll()
		{
			return false;
		}

		@Override
		public void setAutoScroll(boolean autoScroll)
		{
		}

		@Override
		public boolean isPreview()
		{
			return false;
		}

		@Override
		public void setPreview(boolean preview)
		{
		}
	};
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:52,代码来源:UsageContextDataflowToPanel.java


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