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


Java TargetElementUtil.findTargetElement方法代码示例

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


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

示例1: doTest

import consulo.codeInsight.TargetElementUtil; //导入方法依赖的package包/类
protected void doTest(final boolean shouldSucceed) throws Exception {
  final String filePath = getTestFilePath();
  configureByFile(filePath);
  final PsiElement targetElement = TargetElementUtil.findTargetElement(getEditor(), ContainerUtil.newHashSet(TargetElementUtilEx.ELEMENT_NAME_ACCEPTED));
  assertTrue("<caret> is not on method name", targetElement instanceof PsiMember);
  final PsiMember psiMethod = (PsiMember)targetElement;

  try {
    MethodDuplicatesHandler.invokeOnScope(getProject(), psiMethod, new AnalysisScope(getFile()));
  }
  catch (RuntimeException e) {
    if (shouldSucceed) {
      fail("duplicates were not found");
    }
    return;
  }
  UIUtil.dispatchAllInvocationEvents();
  if (shouldSucceed) {
    checkResultByFile(filePath + ".after");
  }
  else {
    fail("duplicates found");
  }
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:25,代码来源:FindMethodDuplicatesBaseTest.java

示例2: testIdWithRefs

import consulo.codeInsight.TargetElementUtil; //导入方法依赖的package包/类
public void testIdWithRefs() throws Exception {
  configureByFiles(null, getTestName(true) + ".fxml");
  PsiElement element = TargetElementUtil
    .findTargetElement(myEditor, ContainerUtil.newHashSet(TargetElementUtilEx.ELEMENT_NAME_ACCEPTED, TargetElementUtilEx.REFERENCED_ELEMENT_ACCEPTED));
  assertNotNull(element);
  new RenameProcessor(getProject(), element, "lb1", true, true).run();
  checkResultByFile(getTestName(true) + "_after.fxml");
}
 
开发者ID:consulo,项目名称:consulo-javafx,代码行数:9,代码来源:JavaFXRenameTest.java

示例3: doTest

import consulo.codeInsight.TargetElementUtil; //导入方法依赖的package包/类
private void doTest(final int targetParameter, final String visibility) throws Exception {
  final String filePath = "/refactoring/convertToInstanceMethod/" + getTestName(false) + ".java";
  configureByFile(filePath);
  final PsiElement targetElement = TargetElementUtil.findTargetElement(getEditor(), ContainerUtil.newHashSet(TargetElementUtilEx.ELEMENT_NAME_ACCEPTED));
  assertTrue("<caret> is not on method name", targetElement instanceof PsiMethod);
  PsiMethod method = (PsiMethod) targetElement;
  new ConvertToInstanceMethodProcessor(getProject(),
                                       method, method.getParameterList().getParameters()[targetParameter],
                                       visibility).run();
  checkResultByFile(filePath + ".after");

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

示例4: perform

import consulo.codeInsight.TargetElementUtil; //导入方法依赖的package包/类
private static void perform(boolean addClassParameter) {
  PsiElement element = TargetElementUtil.findTargetElement(myEditor, ContainerUtil.newHashSet(TargetElementUtilEx.ELEMENT_NAME_ACCEPTED));
  assertTrue(element instanceof PsiMethod);
  PsiMethod method = (PsiMethod) element;

  new MakeMethodStaticProcessor(
          getProject(),
          method,
          new Settings(true, addClassParameter ? "anObject" : null, null)).run();
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:11,代码来源:MakeMethodStaticTest.java

示例5: findElementToShowUsagesOf

import consulo.codeInsight.TargetElementUtil; //导入方法依赖的package包/类
public static PsiNameIdentifierOwner findElementToShowUsagesOf(@Nonnull Editor editor, @Nonnull PsiFile file, int offset) {
  PsiElement elementAt = TargetElementUtil.findTargetElement(editor, ContainerUtil.newHashSet(TargetElementUtilEx.ELEMENT_NAME_ACCEPTED), offset);
  if (elementAt instanceof PsiNameIdentifierOwner) {
    return (PsiNameIdentifierOwner)elementAt;
  }
  return null;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:8,代码来源:GotoDeclarationAction.java

示例6: performInline

import consulo.codeInsight.TargetElementUtil; //导入方法依赖的package包/类
public static void performInline(Project project, Editor editor) {
  PsiElement element = TargetElementUtil
    .findTargetElement(editor, ContainerUtil.newHashSet(TargetElementUtilEx.ELEMENT_NAME_ACCEPTED, TargetElementUtilEx.REFERENCED_ELEMENT_ACCEPTED));
  assertTrue(element instanceof PsiLocalVariable);

  InlineLocalHandler.invoke(project, editor, (PsiLocalVariable)element, null);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:8,代码来源:InlineLocalTest.java

示例7: getPsiElementIn

import consulo.codeInsight.TargetElementUtil; //导入方法依赖的package包/类
@Nullable
private static PsiElement getPsiElementIn(@Nonnull Editor editor, @Nonnull Caret caret, @Nonnull VirtualFile file) {
  final PsiFile psiFile = getPsiFile(editor, file);
  if (psiFile == null) return null;

  try {
    return TargetElementUtil.findTargetElement(editor, TargetElementUtil.getReferenceSearchFlags(), caret.getOffset());
  }
  catch (IndexNotReadyException e) {
    return null;
  }
}
 
开发者ID:consulo,项目名称:consulo,代码行数:13,代码来源:TextEditorPsiDataProvider.java

示例8: doTest

import consulo.codeInsight.TargetElementUtil; //导入方法依赖的package包/类
private void doTest() throws Exception {
  configureByFile(TEST_ROOT + getTestName(true) + ".java");
  PsiElement element = TargetElementUtil.findTargetElement(myEditor, ContainerUtil.newHashSet(TargetElementUtilEx.ELEMENT_NAME_ACCEPTED));
  assertTrue(element instanceof PsiNamedElement);

  final PsiNamedElement namedElement = (PsiNamedElement)element;
  final String name = namedElement.getName();
  new InvertBooleanProcessor(namedElement, name + "Inverted").run();
  checkResultByFile(TEST_ROOT + getTestName(true) + "_after.java");
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:11,代码来源:InvertBooleanTest.java

示例9: performAction

import consulo.codeInsight.TargetElementUtil; //导入方法依赖的package包/类
private void performAction()
{
	PsiElement element = TargetElementUtil.findTargetElement(myEditor, ContainerUtil.newHashSet(TargetElementUtilEx.ELEMENT_NAME_ACCEPTED, TargetElementUtilEx.REFERENCED_ELEMENT_ACCEPTED));
	final PsiReference ref = myFile.findReferenceAt(myEditor.getCaretModel().getOffset());
	PsiReferenceExpression refExpr = ref instanceof PsiReferenceExpression ? (PsiReferenceExpression) ref : null;
	assertTrue(element instanceof PsiField);
	PsiField field = (PsiField) element.getNavigationElement();
	new InlineConstantFieldProcessor(field, getProject(), refExpr, element instanceof PsiCompiledElement).run();
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:10,代码来源:InlineConstantFieldTest.java

示例10: doTestCanBeInvokedOnReference

import consulo.codeInsight.TargetElementUtil; //导入方法依赖的package包/类
private void doTestCanBeInvokedOnReference(boolean canBeInvokedOnReference) throws Exception
{
	configureByFile("/refactoring/inlineToAnonymousClass/" + getTestName(false) + ".java");
	PsiElement element = TargetElementUtil.findTargetElement(myEditor, ContainerUtil.newHashSet(TargetElementUtilEx.ELEMENT_NAME_ACCEPTED, TargetElementUtilEx.REFERENCED_ELEMENT_ACCEPTED));
	PsiCall callToInline = InlineToAnonymousClassHandler.findCallToInline(myEditor);
	PsiClass classToInline = (PsiClass) element;
	assertEquals(null, InlineToAnonymousClassHandler.getCannotInlineMessage(classToInline));
	final PsiClassType superType = InlineToAnonymousClassProcessor.getSuperType(classToInline);
	assertTrue(superType != null);
	assertEquals(canBeInvokedOnReference, InlineToAnonymousClassHandler.canBeInvokedOnReference(callToInline, superType));
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:12,代码来源:InlineToAnonymousClassTest.java

示例11: doTestPreprocessUsages

import consulo.codeInsight.TargetElementUtil; //导入方法依赖的package包/类
private void doTestPreprocessUsages(final String expectedMessage) throws Exception
{
	configureByFile("/refactoring/inlineToAnonymousClass/" + getTestName(false) + ".java");
	PsiElement element = TargetElementUtil.findTargetElement(myEditor, ContainerUtil.newHashSet(TargetElementUtilEx.ELEMENT_NAME_ACCEPTED, TargetElementUtilEx.REFERENCED_ELEMENT_ACCEPTED));
	assertInstanceOf(element, PsiClass.class);
	final PsiClass psiClass = (PsiClass) element;
	assertEquals(expectedMessage, InlineToAnonymousClassHandler.getCannotInlineMessage(psiClass));
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:9,代码来源:InlineToAnonymousClassTest.java

示例12: doTestNoInline

import consulo.codeInsight.TargetElementUtil; //导入方法依赖的package包/类
private void doTestNoInline(final String expectedMessage) throws Exception
{
	String name = getTestName(false);
	@NonNls String fileName = "/refactoring/inlineToAnonymousClass/" + name + ".java";
	configureByFile(fileName);
	PsiElement element = TargetElementUtil.findTargetElement(myEditor, ContainerUtil.newHashSet(TargetElementUtilEx.ELEMENT_NAME_ACCEPTED, TargetElementUtilEx.REFERENCED_ELEMENT_ACCEPTED));
	assertInstanceOf(element, PsiClass.class);

	String message = InlineToAnonymousClassHandler.getCannotInlineMessage((PsiClass) element);
	assertEquals(expectedMessage, message);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:12,代码来源:InlineToAnonymousClassTest.java

示例13: testAllUsagesInCode

import consulo.codeInsight.TargetElementUtil; //导入方法依赖的package包/类
public void testAllUsagesInCode() throws Exception {
  configureByFile(BASE_PATH + getTestName(false) + ".java");
  PsiElement element = TargetElementUtil
      .findTargetElement(myEditor, ContainerUtil.newHashSet(TargetElementUtilEx.ELEMENT_NAME_ACCEPTED, TargetElementUtilEx.REFERENCED_ELEMENT_ACCEPTED));
  assertNotNull(element);
  final UsageInfo[] usageInfos = RenameUtil.findUsages(element, "newName", true, true, new HashMap<PsiElement, String>());
  assertSize(1, usageInfos);
  for (UsageInfo usageInfo : usageInfos) {
    assertTrue(usageInfo instanceof MoveRenameUsageInfo);
    assertFalse(usageInfo.isNonCodeUsage);
  }
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:13,代码来源:RenameCollisionsTest.java

示例14: testRenameParamUniqueName

import consulo.codeInsight.TargetElementUtil; //导入方法依赖的package包/类
public void testRenameParamUniqueName() throws Exception {
  configureByFile(BASE_PATH + getTestName(false) + ".java");
  PsiElement element = TargetElementUtil
    .findTargetElement(myEditor, ContainerUtil.newHashSet(TargetElementUtilEx.ELEMENT_NAME_ACCEPTED,TargetElementUtilEx.REFERENCED_ELEMENT_ACCEPTED));
  assertNotNull(element);
  final HashSet<String> result = new HashSet<String>();
  new JavaNameSuggestionProvider().getSuggestedNames(element, getFile(), result);
  assertTrue(result.toString(), result.contains("window"));
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:10,代码来源:RenameLocalTest.java

示例15: doTest

import consulo.codeInsight.TargetElementUtil; //导入方法依赖的package包/类
private void doTest(boolean isTargetParameter, final int targetIndex, final String newVisibility) throws Exception {
  final String filePath = "/refactoring/moveInstanceMethod/" + getTestName(false) + ".java";
  configureByFile(filePath);
  final PsiElement targetElement = TargetElementUtil.findTargetElement(getEditor(), ContainerUtil.newHashSet(TargetElementUtilEx.ELEMENT_NAME_ACCEPTED));
  assertTrue("<caret> is not on method name", targetElement instanceof PsiMethod);
  PsiMethod method = (PsiMethod) targetElement;
  final PsiVariable targetVariable = isTargetParameter ? method.getParameterList().getParameters()[targetIndex] :
                                     method.getContainingClass().getFields()[targetIndex];
  new MoveInstanceMethodProcessor(getProject(),
                                  method, targetVariable, newVisibility, MoveInstanceMethodHandler.suggestParameterNames (method, targetVariable)).run();
  checkResultByFile(filePath + ".after");

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


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