• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java TargetElementUtilEx类的典型用法和代码示例

java 1次浏览

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

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

示例1: searchImplementations

点赞 3

import consulo.codeInsight.TargetElementUtilEx; //导入依赖的package包/类
@Nullable
PsiElement[] searchImplementations(Editor editor, PsiElement element, int offset) {
  boolean onRef = ApplicationManager.getApplication().runReadAction((Computable<Boolean>)() -> {
    Set<String> flags = ContainerUtil.newHashSet(getFlags());
    flags.remove(TargetElementUtilEx.REFERENCED_ELEMENT_ACCEPTED);
    flags.remove(TargetElementUtilEx.LOOKUP_ITEM_ACCEPTED);

    return TargetElementUtil.findTargetElement(editor, flags, offset) == null;
  });
  return searchImplementations(element, editor, onRef &&
                                                ApplicationManager.getApplication().runReadAction((Computable<Boolean>)() -> element == null ||
                                                                                                                             TargetElementUtil
                                                                                                                                     .includeSelfInGotoImplementation(
                                                                                                                                             element)),
                               onRef);
}
 

开发者ID:consulo,
项目名称:consulo,
代码行数:17,
代码来源:ImplementationSearcher.java

示例2: performWithFields

点赞 3

import consulo.codeInsight.TargetElementUtilEx; //导入依赖的package包/类
private void performWithFields() throws Exception {
  configureByFile(TEST_ROOT + getTestName(false) + ".java");
  PsiElement element = TargetElementUtil.findTargetElement(myEditor, ContainerUtil.newHashSet(TargetElementUtilEx.ELEMENT_NAME_ACCEPTED));
  assertTrue(element instanceof PsiClass);
  PsiClass aClass = (PsiClass)element;
  final ArrayList<VariableData> parametersForFields = new ArrayList<VariableData>();
  final boolean addClassParameter = MakeStaticUtil.buildVariableData(aClass, parametersForFields);

  new MakeClassStaticProcessor(
          getProject(),
          aClass,
          new Settings(true, addClassParameter ? "anObject" : null,
                       parametersForFields.toArray(
                         new VariableData[parametersForFields.size()]))).run();
  checkResultByFile(TEST_ROOT + getTestName(false) + "_after.java");
}
 

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

示例3: doTest

点赞 3

import consulo.codeInsight.TargetElementUtilEx; //导入依赖的package包/类
private void doTest(@PsiModifier.ModifierConstant @Nullable String newVisibility,
		@Nullable String newName,
		@Nullable String newReturnType,
		GenParams genParams,
		GenExceptions genExceptions,
		final boolean generateDelegate) throws Exception
{
	String basePath = "/refactoring/changeSignature/" + getTestName(false);
	@NonNls final String filePath = basePath + ".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 PsiElementFactory factory = JavaPsiFacade.getInstance(getProject()).getElementFactory();
	PsiType newType = newReturnType != null ? factory.createTypeFromText(newReturnType, method) : method.getReturnType();
	new ChangeSignatureProcessor(getProject(), method, generateDelegate, newVisibility, newName != null ? newName : method.getName(), newType, genParams.genParams(method), genExceptions
			.genExceptions(method)).run();
	@NonNls String after = basePath + "_after.java";
	checkResultByFile(after);
}
 

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

示例4: testPropagateParameter

点赞 3

import consulo.codeInsight.TargetElementUtilEx; //导入依赖的package包/类
public void testPropagateParameter() throws Exception
{
	String basePath = "/refactoring/changeSignature/" + getTestName(false);
	@NonNls final String filePath = basePath + ".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 PsiClass containingClass = method.getContainingClass();
	assertTrue(containingClass != null);
	final PsiMethod[] callers = containingClass.findMethodsByName("caller", false);
	assertTrue(callers.length > 0);
	final PsiMethod caller = callers[0];
	final HashSet<PsiMethod> propagateParametersMethods = new HashSet<PsiMethod>();
	propagateParametersMethods.add(caller);
	final PsiParameter[] parameters = method.getParameterList().getParameters();
	new ChangeSignatureProcessor(getProject(), method, false, null, method.getName(), CanonicalTypes.createTypeWrapper(PsiType.VOID), new ParameterInfoImpl[]{
			new ParameterInfoImpl(0, parameters[0].getName(), parameters[0].getType()),
			new ParameterInfoImpl(-1, "b", PsiType.BOOLEAN, "true")
	}, null, propagateParametersMethods, null).run();
	@NonNls String after = basePath + "_after.java";
	checkResultByFile(after);
}
 

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

示例5: doTest

点赞 3

import consulo.codeInsight.TargetElementUtilEx; //导入依赖的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

示例6: doTest

点赞 3

import consulo.codeInsight.TargetElementUtilEx; //导入依赖的package包/类
private void doTest(final boolean createInnerClass) throws Exception {
  final String testName = getTestName(false);
  configureByFile("/refactoring/extractMethodObject/" + testName + ".java");
  PsiElement element = TargetElementUtil.findTargetElement(myEditor, ContainerUtil.newHashSet(TargetElementUtilEx.ELEMENT_NAME_ACCEPTED));
  assertTrue(element instanceof PsiMethod);
  final PsiMethod method = (PsiMethod) element;

  final ExtractMethodObjectProcessor processor =
    new ExtractMethodObjectProcessor(getProject(), getEditor(), method.getBody().getStatements(), "InnerClass");
  final ExtractMethodObjectProcessor.MyExtractMethodProcessor extractProcessor = processor.getExtractProcessor();
  processor.setCreateInnerClass(createInnerClass);
  extractProcessor.setShowErrorDialogs(false);
  extractProcessor.prepare();
  extractProcessor.testPrepare();

  ApplicationManager.getApplication().runWriteAction(new Runnable() {
    public void run() {
      ExtractMethodObjectHandler.run(getProject(), getEditor(), processor, extractProcessor);
    }
  });


  checkResultByFile("/refactoring/extractMethodObject/" + testName + ".java" + ".after");
}
 

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

示例7: testIdWithRefs

点赞 2

import consulo.codeInsight.TargetElementUtilEx; //导入依赖的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

示例8: doTest

点赞 2

import consulo.codeInsight.TargetElementUtilEx; //导入依赖的package包/类
private void doTest(final String newName, boolean inline) throws Exception {
  configureByFiles(null, getTestName(true) + ".fxml", getTestName(false) + ".java");
  PsiElement element = TargetElementUtil
    .findTargetElement(myEditor, ContainerUtil.newHashSet(TargetElementUtilEx.ELEMENT_NAME_ACCEPTED, TargetElementUtilEx.REFERENCED_ELEMENT_ACCEPTED));
  assertNotNull(element);
  if (inline) {
    CodeInsightTestUtil.doInlineRename(new MemberInplaceRenameHandler(), newName, getEditor(), element);
  } else {
    new RenameProcessor(getProject(), element, newName, true, true).run();
  }
  checkResultByFile(getTestName(true) + "_after.fxml");
}
 

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

示例9: findElementToShowUsagesOf

点赞 2

import consulo.codeInsight.TargetElementUtilEx; //导入依赖的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

示例10: invoke

点赞 2

import consulo.codeInsight.TargetElementUtilEx; //导入依赖的package包/类
@RequiredDispatchThread
public void invoke(@NotNull final Project project, final Editor editor, PsiFile file, DataContext dataContext)
{
	PsiElement element = TargetElementUtil.findTargetElement(editor, ContainerUtil.newHashSet(TargetElementUtilEx.ELEMENT_NAME_ACCEPTED,
			TargetElementUtilEx.REFERENCED_ELEMENT_ACCEPTED, TargetElementUtilEx.LOOKUP_ITEM_ACCEPTED));
	editor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE);
	if(!(element instanceof PsiLocalVariable))
	{
		String message = RefactoringBundle.getCannotRefactorMessage(RefactoringBundle.message("error.wrong.caret.position.local.name"));
		CommonRefactoringUtil.showErrorHint(project, editor, message, REFACTORING_NAME, HelpID.REPLACE_TEMP_WITH_QUERY);
		return;
	}

	invokeOnVariable(file, project, (PsiLocalVariable) element, editor);
}
 

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

示例11: doTest

点赞 2

import consulo.codeInsight.TargetElementUtilEx; //导入依赖的package包/类
private void doTest(final String newName) 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);
  new RenameProcessor(getProject(), element, newName, true, true).run();
  checkResultByFile(BASE_PATH + getTestName(false) + ".java.after");
}
 

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

示例12: testAllUsagesInCode

点赞 2

import consulo.codeInsight.TargetElementUtilEx; //导入依赖的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

示例13: testRenameParamUniqueName

点赞 2

import consulo.codeInsight.TargetElementUtilEx; //导入依赖的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

示例14: doTest

点赞 2

import consulo.codeInsight.TargetElementUtilEx; //导入依赖的package包/类
private void doTest(final String newName) 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);
  new RenameProcessor(getProject(), element, newName, true, true).run();
  checkResultByFile(BASE_PATH + getTestName(false) + "_after.java");
}
 

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

示例15: doTestInplaceRename

点赞 2

import consulo.codeInsight.TargetElementUtilEx; //导入依赖的package包/类
private void doTestInplaceRename(final String newName) throws Exception {
  configureByFile(BASE_PATH + "/" + getTestName(false) + ".java");

  final PsiElement element = TargetElementUtil.findTargetElement(myEditor, ContainerUtil.newHashSet(TargetElementUtilEx.ELEMENT_NAME_ACCEPTED, TargetElementUtilEx.REFERENCED_ELEMENT_ACCEPTED));
  assertNotNull(element);
  assertTrue("In-place rename not allowed for " + element,
             JavaRefactoringSupportProvider.mayRenameInplace(element, null));

  CodeInsightTestUtil.doInlineRename(new VariableInplaceRenameHandler(), newName, getEditor(), element);

  checkResultByFile(BASE_PATH + getTestName(false) + "_after.java");
}
 

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

示例16: perform

点赞 2

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

  boolean addClassParameter = MakeStaticUtil.isParameterNeeded(aClass);

  new MakeClassStaticProcessor(
          getProject(),
          aClass,
          new Settings(true, addClassParameter ? "anObject" : null, null)).run();
  checkResultByFile(TEST_ROOT + getTestName(false) + "_after.java");
}
 

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

示例17: getPrimaryMethod

点赞 2

import consulo.codeInsight.TargetElementUtilEx; //导入依赖的package包/类
private PsiMethod getPrimaryMethod() throws Exception {
  final String filePath = getBasePath() + getTestName(false) + ".java";
  configureByFile(filePath);
  final PsiElement targetElement = TargetElementUtil.findTargetElement(myEditor, ContainerUtil.newHashSet(TargetElementUtilEx.ELEMENT_NAME_ACCEPTED));
  assertTrue("<caret> is not on method name", targetElement instanceof PsiMethod);
  return (PsiMethod) targetElement;
}
 

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

示例18: perform

点赞 2

import consulo.codeInsight.TargetElementUtilEx; //导入依赖的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

示例19: performWithFields

点赞 2

import consulo.codeInsight.TargetElementUtilEx; //导入依赖的package包/类
private static void performWithFields() {
  PsiElement element = TargetElementUtil.findTargetElement(myEditor, ContainerUtil.newHashSet(TargetElementUtilEx.ELEMENT_NAME_ACCEPTED));
  assertTrue(element instanceof PsiMethod);
  PsiMethod method = (PsiMethod) element;
  final ArrayList<VariableData> parametersForFields = new ArrayList<VariableData>();
  final boolean addClassParameter = MakeStaticUtil.buildVariableData(method, parametersForFields);

  new MakeMethodStaticProcessor(
          getProject(),
          method,
          new Settings(true, addClassParameter ? "anObject" : null,
                       parametersForFields.toArray(
                         new VariableData[parametersForFields.size()]))).run();
}
 

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

示例20: doTest

点赞 2

import consulo.codeInsight.TargetElementUtilEx; //导入依赖的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

示例21: doTest

点赞 2

import consulo.codeInsight.TargetElementUtilEx; //导入依赖的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

示例22: doTest

点赞 2

import consulo.codeInsight.TargetElementUtilEx; //导入依赖的package包/类
private void doTest(GenParams gen, @NonNls String filePathBefore, @NonNls String filePathAfter) throws Exception {
  final String filePath = DATA_PATH + filePathBefore;
  configureByFile(filePath);
  final PsiElement targetElement = TargetElementUtil.findTargetElement(getEditor(), ContainerUtil.newHashSet(TargetElementUtilEx.ELEMENT_NAME_ACCEPTED));
  assertTrue("<caret> is not on class name", targetElement instanceof PsiClass);
  PsiClass aClass = (PsiClass)targetElement;
  new ChangeClassSignatureProcessor(getProject(), aClass, gen.gen(aClass)).run();
  checkResultByFile(DATA_PATH + filePathAfter);
}
 

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

示例23: performAction

点赞 2

import consulo.codeInsight.TargetElementUtilEx; //导入依赖的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

示例24: performAction

点赞 2

import consulo.codeInsight.TargetElementUtilEx; //导入依赖的package包/类
private void performAction(final InlineOptions options, final boolean nonCode) {
  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 PsiMethod);
  PsiMethod method = (PsiMethod)element;
  final boolean condition = InlineMethodProcessor.checkBadReturns(method) && !InlineUtil.allUsagesAreTailCalls(method);
  assertFalse("Bad returns found", condition);
  final InlineMethodProcessor processor =
    new InlineMethodProcessor(getProject(), method, refExpr, myEditor, options.isInlineThisOnly(), nonCode, nonCode);
  processor.run();
}
 

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

示例25: performInline

点赞 2

import consulo.codeInsight.TargetElementUtilEx; //导入依赖的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

示例26: doTestNoInline

点赞 2

import consulo.codeInsight.TargetElementUtilEx; //导入依赖的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

示例27: doTestPreprocessUsages

点赞 2

import consulo.codeInsight.TargetElementUtilEx; //导入依赖的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

示例28: prepareProcessor

点赞 2

import consulo.codeInsight.TargetElementUtilEx; //导入依赖的package包/类
private InlineToAnonymousClassProcessor prepareProcessor() 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);

	assertEquals(null, InlineToAnonymousClassHandler.getCannotInlineMessage((PsiClass) element));
	return new InlineToAnonymousClassProcessor(getProject(), (PsiClass) element, null, false, false, false);
}
 

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

示例29: performAction

点赞 2

import consulo.codeInsight.TargetElementUtilEx; //导入依赖的package包/类
private void performAction(final boolean inlineThisOnly, final boolean searchInNonJavaFiles)
{
	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 InlineToAnonymousClassProcessor processor = new InlineToAnonymousClassProcessor(getProject(), classToInline, callToInline, inlineThisOnly, false, searchInNonJavaFiles);
	UsageInfo[] usages = processor.findUsages();
	MultiMap<PsiElement, String> conflicts = processor.getConflicts(usages);
	assertEquals(0, conflicts.size());
	processor.run();
}
 

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

示例30: doTestCanBeInvokedOnReference

点赞 2

import consulo.codeInsight.TargetElementUtilEx; //导入依赖的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

示例31: doTest

点赞 2

import consulo.codeInsight.TargetElementUtilEx; //导入依赖的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

示例32: doCollectInformation

点赞 2

import consulo.codeInsight.TargetElementUtilEx; //导入依赖的package包/类
@Override
public void doCollectInformation(@Nonnull final ProgressIndicator progress) {
  if (myHighlightUsagesHandler != null) {
    List<PsiElement> targets = myHighlightUsagesHandler.getTargets();
    myHighlightUsagesHandler.computeUsages(targets);
    final List<TextRange> readUsages = myHighlightUsagesHandler.getReadUsages();
    for (TextRange readUsage : readUsages) {
      LOG.assertTrue(readUsage != null, "null text range from " + myHighlightUsagesHandler);
    }
    myReadAccessRanges.addAll(readUsages);
    final List<TextRange> writeUsages = myHighlightUsagesHandler.getWriteUsages();
    for (TextRange writeUsage : writeUsages) {
      LOG.assertTrue(writeUsage != null, "null text range from " + myHighlightUsagesHandler);
    }
    myWriteAccessRanges.addAll(writeUsages);
    if (!myHighlightUsagesHandler.highlightReferences()) return;
  }

  Set<String> flags = ContainerUtil.newHashSet(TargetElementUtilEx.ELEMENT_NAME_ACCEPTED, TargetElementUtilEx.REFERENCED_ELEMENT_ACCEPTED);
  PsiElement myTarget = TargetElementUtil.findTargetElement(myEditor, flags, myCaretOffset);

  if (myTarget == null) {
    if (!PsiDocumentManager.getInstance(myProject).isUncommited(myEditor.getDocument())) {
      // when document is committed, try to check injected stuff - it's fast
      Editor injectedEditor = InjectedLanguageUtil.getEditorForInjectedLanguageNoCommit(myEditor, myFile, myCaretOffset);
      myTarget = TargetElementUtil.findTargetElement(injectedEditor, flags, injectedEditor.getCaretModel().getOffset());
    }
  }

  if (myTarget != null) {
    highlightTargetUsages(myTarget);
  } else {
    PsiReference ref = TargetElementUtil.findReference(myEditor);
    if (ref instanceof PsiPolyVariantReference) {
      if (!ref.getElement().isValid()) {
        throw new PsiInvalidElementAccessException(ref.getElement(), "Invalid element in " + ref + " of " + ref.getClass() + "; editor=" + myEditor);
      }
      ResolveResult[] results = ((PsiPolyVariantReference)ref).multiResolve(false);
      if (results.length > 0) {
        for (ResolveResult result : results) {
          PsiElement target = result.getElement();
          if (target != null) {
            if (!target.isValid()) {
              throw new PsiInvalidElementAccessException(target, "Invalid element returned from " + ref + " of " + ref.getClass() + "; editor=" + myEditor);
            }
            highlightTargetUsages(target);
          }
        }
      }
    }

  }
}
 

开发者ID:consulo,
项目名称:consulo,
代码行数:54,
代码来源:IdentifierHighlighterPass.java

示例33: getSelection

点赞 2

import consulo.codeInsight.TargetElementUtilEx; //导入依赖的package包/类
@RequiredDispatchThread
public VcsSelection getSelection(VcsContext context)
{
	final Editor editor = context.getEditor();
	if(editor == null)
	{
		return null;
	}
	PsiElement psiElement = TargetElementUtil.findTargetElement(editor, ContainerUtil.newHashSet(TargetElementUtilEx.ELEMENT_NAME_ACCEPTED));
	if(psiElement == null || !psiElement.isValid())
	{
		return null;
	}

	final String actionName;

	if(psiElement instanceof XmlTag)
	{
		actionName = VcsBundle.message("action.name.show.history.for.tag");
	}
	else if(psiElement instanceof XmlText)
	{
		actionName = VcsBundle.message("action.name.show.history.for.text");
	}
	else
	{
		return null;
	}

	TextRange textRange = psiElement.getTextRange();
	if(textRange == null)
	{
		return null;
	}

	VirtualFile virtualFile = psiElement.getContainingFile().getVirtualFile();
	if(virtualFile == null)
	{
		return null;
	}
	if(!virtualFile.isValid())
	{
		return null;
	}

	Document document = FileDocumentManager.getInstance().getDocument(virtualFile);
	return new VcsSelection(document, textRange, actionName);
}
 

开发者ID:consulo,
项目名称:consulo-xml,
代码行数:49,
代码来源:XmlVcsSelectionProvider.java

示例34: getSelection

点赞 2

import consulo.codeInsight.TargetElementUtilEx; //导入依赖的package包/类
@Nullable
@RequiredDispatchThread
public VcsSelection getSelection(final VcsContext context) {
  final Editor editor = context.getEditor();
  if (editor == null) return null;
  PsiElement psiElement = TargetElementUtil.findTargetElement(editor, ContainerUtil.newHashSet(TargetElementUtilEx.ELEMENT_NAME_ACCEPTED));
  if (psiElement == null) {
    return null;
  }
  if (!psiElement.isValid()) {
    return null;
  }
  if (psiElement instanceof PsiCompiledElement) {
    return null;
  }

  final String actionName;

  if (psiElement instanceof PsiClass) {
    actionName = VcsBundle.message("action.name.show.history.for.class");
  }
  else if (psiElement instanceof PsiField) {
    actionName = VcsBundle.message("action.name.show.history.for.field");
  }
  else if (psiElement instanceof PsiMethod) {
    actionName = VcsBundle.message("action.name.show.history.for.method");
  }
  else if (psiElement instanceof PsiCodeBlock) {
    actionName = VcsBundle.message("action.name.show.history.for.code.block");
  }
  else if (psiElement instanceof PsiStatement) {
    actionName = VcsBundle.message("action.name.show.history.for.statement");
  }
  else {
    return null;
  }

  TextRange textRange = psiElement.getTextRange();
  if (textRange == null) {
    return null;
  }

  VirtualFile virtualFile = psiElement.getContainingFile().getVirtualFile();
  if (virtualFile == null) {
    return null;
  }
  if (!virtualFile.isValid()) {
    return null;
  }

  Document document = FileDocumentManager.getInstance().getDocument(virtualFile);
  return new VcsSelection(document, textRange, actionName);
}
 

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

示例35: performAction

点赞 2

import consulo.codeInsight.TargetElementUtilEx; //导入依赖的package包/类
private void performAction() {
  final PsiElement psiElement = TargetElementUtil
    .findTargetElement(myEditor, ContainerUtil.newHashSet(TargetElementUtilEx.ELEMENT_NAME_ACCEPTED, TargetElementUtilEx.REFERENCED_ELEMENT_ACCEPTED));
  assertNotNull("No element found in text:\n" + getFile().getText(), psiElement);
  SafeDeleteHandler.invoke(getProject(), new PsiElement[]{psiElement}, true);
}
 

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

示例36: testInnerStaticClassUsed

点赞 2

import consulo.codeInsight.TargetElementUtilEx; //导入依赖的package包/类
public void testInnerStaticClassUsed() throws Exception {
  configureByFile("/refactoring/makeMethodStatic/beforeInnerStaticClassUsed.java");
  PsiElement element = TargetElementUtil.findTargetElement(myEditor, ContainerUtil.newHashSet(TargetElementUtilEx.ELEMENT_NAME_ACCEPTED));
  assertTrue(element instanceof PsiMethod);
  assertFalse(MakeStaticUtil.isParameterNeeded((PsiMethod)element));
}
 

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

示例37: performAction

点赞 2

import consulo.codeInsight.TargetElementUtilEx; //导入依赖的package包/类
private static void performAction() {
  final PsiElement element = TargetElementUtil.findTargetElement(myEditor, ContainerUtil.newHashSet(TargetElementUtilEx
	.REFERENCED_ELEMENT_ACCEPTED, TargetElementUtilEx.ELEMENT_NAME_ACCEPTED));
  new InlineParameterHandler().inlineElement(getProject(), myEditor, element);
}
 

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

示例38: perform

点赞 2

import consulo.codeInsight.TargetElementUtilEx; //导入依赖的package包/类
protected static void perform(String newName)
{
	PsiElement element = TargetElementUtil.findTargetElement(myEditor, ContainerUtil.newHashSet(TargetElementUtilEx.ELEMENT_NAME_ACCEPTED, TargetElementUtilEx.REFERENCED_ELEMENT_ACCEPTED));

	new RenameProcessor(getProject(), element, newName, false, false).run();
}
 

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


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)