Search in sources :

Example 1 with JavaNameSuggestionProvider

use of com.intellij.refactoring.rename.JavaNameSuggestionProvider in project intellij-community by JetBrains.

the class RenameLocalTest method testRenameParamUniqueName.

public void testRenameParamUniqueName() throws Exception {
    configureByFile(BASE_PATH + getTestName(false) + ".java");
    PsiElement element = TargetElementUtil.findTargetElement(myEditor, TargetElementUtil.ELEMENT_NAME_ACCEPTED | TargetElementUtil.REFERENCED_ELEMENT_ACCEPTED);
    assertNotNull(element);
    final HashSet<String> result = new HashSet<>();
    new JavaNameSuggestionProvider().getSuggestedNames(element, getFile(), result);
    assertTrue(result.toString(), result.contains("window"));
}
Also used : JavaNameSuggestionProvider(com.intellij.refactoring.rename.JavaNameSuggestionProvider) PsiElement(com.intellij.psi.PsiElement) HashSet(java.util.HashSet)

Example 2 with JavaNameSuggestionProvider

use of com.intellij.refactoring.rename.JavaNameSuggestionProvider in project intellij-community by JetBrains.

the class RenameMembersInplaceTest method testNameSuggestion.

public void testNameSuggestion() throws Exception {
    configureByFile(BASE_PATH + "/" + getTestName(false) + ".java");
    final PsiElement element = TargetElementUtil.findTargetElement(myEditor, TargetElementUtil.getInstance().getAllAccepted());
    assertNotNull(element);
    final Set<String> result = new LinkedHashSet<>();
    new JavaNameSuggestionProvider().getSuggestedNames(element, getFile(), result);
    CodeInsightTestUtil.doInlineRename(new MemberInplaceRenameHandler(), result.iterator().next(), getEditor(), element);
    checkResultByFile(BASE_PATH + getTestName(false) + "_after.java");
}
Also used : LinkedHashSet(java.util.LinkedHashSet) MemberInplaceRenameHandler(com.intellij.refactoring.rename.inplace.MemberInplaceRenameHandler) JavaNameSuggestionProvider(com.intellij.refactoring.rename.JavaNameSuggestionProvider) PsiElement(com.intellij.psi.PsiElement)

Aggregations

PsiElement (com.intellij.psi.PsiElement)2 JavaNameSuggestionProvider (com.intellij.refactoring.rename.JavaNameSuggestionProvider)2 MemberInplaceRenameHandler (com.intellij.refactoring.rename.inplace.MemberInplaceRenameHandler)1 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1