use of com.intellij.psi.PsiReference in project intellij-plugins by JetBrains.
the class FlexRenameTest method testRenameClassTwoTimes.
public void testRenameClassTwoTimes() throws Exception {
final String name = getTestName(false);
VirtualFile file = getVirtualFile(getBasePath() + name + "/mytest/foo/" + name + "_2.js2");
VirtualFile[] files = { getVirtualFile(getBasePath() + name + "/mytest/boo/" + name + ".js2"), file };
configureByFiles(new File(getTestDataPath() + getBasePath() + name), files);
int referencesCount = findRenamedRefsToReferencedElementAtCaret().length;
performAction(name + "_3", true);
checkResultByFile(getBasePath() + name + "_after.js2");
assertEquals(referencesCount, findRenamedRefsToReferencedElementAtCaret().length);
performAction(name + "_4", true);
checkResultByFile(getBasePath() + name + "_after2.js2");
PsiReference[] refs = findRenamedRefsToReferencedElementAtCaret();
assertEquals(referencesCount, refs.length);
for (PsiReference ref : refs) {
PsiElement refElement = ref.getElement();
PsiElement refElementParent = refElement.getParent();
assertFalse(refElementParent instanceof JSReferenceExpression);
if (!(refElementParent instanceof JSImportStatement)) {
assertEquals(name + "_4", refElement.getText());
}
}
}
use of com.intellij.psi.PsiReference in project android by JetBrains.
the class AndroidGotoDeclarationHandlerTest method getDeclarationsFrom.
@Nullable
private PsiElement[] getDeclarationsFrom(VirtualFile file) {
myFixture.configureFromExistingVirtualFile(file);
// AndroidGotoDeclarationHandler only handles .java files. We also want to check .xml files, so
// we use GotoDeclarationAction instead of creating AndroidGotoDeclarationHandler and invoking getGotoDeclarationTargets
// on it directly.
PsiElement[] elements = GotoDeclarationAction.findAllTargetElements(myFixture.getProject(), myFixture.getEditor(), myFixture.getCaretOffset());
if (elements.length == 0) {
final PsiReference reference = TargetElementUtil.findReference(myFixture.getEditor(), myFixture.getCaretOffset());
if (reference != null) {
final Collection<PsiElement> candidates = TargetElementUtil.getInstance().getTargetCandidates(reference);
elements = PsiUtilCore.toPsiElementArray(candidates);
}
}
return elements;
}
use of com.intellij.psi.PsiReference in project intellij-plugins by JetBrains.
the class FiltersTest method testFilterBuiltinResolve.
public void testFilterBuiltinResolve() {
myFixture.configureByFiles("filterBuiltin.resolve.html", "angular.js");
int offsetBySignature = AngularTestUtil.findOffsetBySignature("js<caret>on", myFixture.getFile());
PsiReference ref = myFixture.getFile().findReferenceAt(offsetBySignature);
assertNotNull(ref);
PsiElement resolve = ref.resolve();
assertNotNull(resolve);
assertEquals("angular.js", resolve.getContainingFile().getName());
}
use of com.intellij.psi.PsiReference in project intellij-plugins by JetBrains.
the class FiltersTest method testPipeResolve.
public void testPipeResolve() {
JSTestUtils.testWithinLanguageLevel(JSLanguageLevel.ES6, getProject(), () -> {
myFixture.configureByFiles("filterCustom.resolve.html", "angular2.js", "custom.ts");
int offsetBySignature = AngularTestUtil.findOffsetBySignature("fil<caret>ta", myFixture.getFile());
PsiReference ref = myFixture.getFile().findReferenceAt(offsetBySignature);
assertNotNull(ref);
PsiElement resolve = ref.resolve();
assertNotNull(resolve);
assertEquals("custom.ts", resolve.getContainingFile().getName());
assertEquals("Pipe({\n" + " name: \"filta\"\n" + "})", resolve.getParent().getText());
});
}
use of com.intellij.psi.PsiReference in project intellij-plugins by JetBrains.
the class FiltersTest method testFilterCustomResolve.
public void testFilterCustomResolve() {
myFixture.configureByFiles("filterCustom.resolve.html", "angular.js", "custom.js");
int offsetBySignature = AngularTestUtil.findOffsetBySignature("fil<caret>ta", myFixture.getFile());
PsiReference ref = myFixture.getFile().findReferenceAt(offsetBySignature);
assertNotNull(ref);
PsiElement resolve = ref.resolve();
assertNotNull(resolve);
assertEquals("custom.js", resolve.getContainingFile().getName());
assertEquals("\"filta\"", resolve.getParent().getText());
}
Aggregations