use of com.intellij.psi.PsiReference in project intellij-community by JetBrains.
the class PyResolveTest method testLoopToUpperReassignment.
// PY-7541
public void testLoopToUpperReassignment() {
final PsiReference ref = findReferenceByMarker();
final PsiElement source = ref.getElement();
final PsiElement target = ref.resolve();
assertNotNull(target);
assertTrue(source != target);
assertTrue(PyPsiUtils.isBefore(target, source));
}
use of com.intellij.psi.PsiReference in project intellij-community by JetBrains.
the class PyResolveTest method multiResolve.
private ResolveResult[] multiResolve() {
PsiReference ref = findReferenceByMarker();
assertTrue(ref instanceof PsiPolyVariantReference);
return ((PsiPolyVariantReference) ref).multiResolve(false);
}
use of com.intellij.psi.PsiReference in project intellij-community by JetBrains.
the class DomCompletionContributor method domKnowsBetter.
private boolean domKnowsBetter(final CompletionParameters parameters, final CompletionResultSet result) {
final XmlAttributeValue element = PsiTreeUtil.getParentOfType(parameters.getPosition(), XmlAttributeValue.class);
if (element == null) {
return false;
}
if (isSchemaEnumerated(element)) {
return false;
}
final PsiElement parent = element.getParent();
if (parent instanceof XmlAttribute) {
XmlAttributeDescriptor descriptor = ((XmlAttribute) parent).getDescriptor();
if (descriptor != null && descriptor.getDefaultValue() != null) {
final PsiReference[] references = myProvider.getReferencesByElement(element, new ProcessingContext());
if (references.length > 0) {
return LegacyCompletionContributor.completeReference(parameters, result);
}
}
}
return false;
}
use of com.intellij.psi.PsiReference in project intellij-community by JetBrains.
the class GrChangeSignatureHandler method findTargetMember.
@Override
@Nullable
public PsiElement findTargetMember(PsiElement element) {
final GrParameterList parameterList = PsiTreeUtil.getParentOfType(element, GrParameterList.class);
if (parameterList != null) {
final PsiElement parent = parameterList.getParent();
if (parent instanceof PsiMethod)
return parent;
}
if (element.getParent() instanceof GrMethod && ((GrMethod) element.getParent()).getNameIdentifierGroovy() == element) {
return element.getParent();
}
final GrCall expression = PsiTreeUtil.getParentOfType(element, GrCall.class);
if (expression != null) {
return expression.resolveMethod();
}
final PsiReference ref = element.getReference();
if (ref == null)
return null;
return ref.resolve();
}
use of com.intellij.psi.PsiReference in project intellij-community by JetBrains.
the class DependencyVisitor method visitPyCallExpression.
@Override
public void visitPyCallExpression(@NotNull final PyCallExpression node) {
final PyExpression callee = node.getCallee();
if (callee != null) {
final PsiReference calleeReference = callee.getReference();
if ((calleeReference != null) && calleeReference.isReferenceTo(myElementToFind)) {
myDependencyFound = true;
return;
}
final String calleeName = callee.getName();
final String name = myElementToFind.getName();
if ((calleeName != null) && calleeName.equals(name)) {
// Check by name also
myDependencyFound = true;
}
// Member could be used as method param
final PyArgumentList list = node.getArgumentList();
if (list != null) {
for (final PyExpression expression : node.getArgumentList().getArgumentExpressions()) {
final PsiReference reference = expression.getReference();
if ((reference != null) && reference.isReferenceTo(myElementToFind)) {
myDependencyFound = true;
}
if ((name != null) && name.equals(expression.getName())) {
myDependencyFound = true;
}
}
}
}
}
Aggregations