use of com.jetbrains.python.psi.PyExpression in project intellij-community by JetBrains.
the class PySmartStepIntoHandler method addVariants.
private static void addVariants(Document document, int line, @Nullable PsiElement element, List<PySmartStepIntoVariant> variants, Set<PyCallExpression> visited) {
if (element == null)
return;
final PyCallExpression expression = PsiTreeUtil.getParentOfType(element, PyCallExpression.class);
if (expression != null && expression.getTextRange().getEndOffset() <= document.getLineEndOffset(line) && visited.add(expression)) {
addVariants(document, line, expression.getParent(), variants, visited);
PyExpression ref = expression.getCallee();
variants.add(new PySmartStepIntoVariant(ref));
}
}
use of com.jetbrains.python.psi.PyExpression in project intellij-community by JetBrains.
the class PyDecoratorTest method testDecoParamCall.
public void testDecoParamCall() throws Exception {
PsiElement targetElement = find().getParent();
assertTrue(targetElement instanceof PyDecorator);
PyDecorator deco = (PyDecorator) targetElement;
PyFunction decofun = deco.getTarget();
assertNotNull(decofun);
assertEquals("foo", decofun.getName());
assertFalse(deco.isBuiltin());
assertTrue(deco.hasArgumentList());
PyArgumentList arglist = deco.getArgumentList();
assertNotNull(arglist);
PyExpression[] args = arglist.getArguments();
assertEquals("argument count", 1, args.length);
assertEquals("argument value", "1", args[0].getText());
}
use of com.jetbrains.python.psi.PyExpression in project intellij-community by JetBrains.
the class PyAssignmentMappingTest method testSubscribedSource.
public void testSubscribedSource() throws Exception {
Map<String, PsiElement> marks = loadTest();
Assert.assertEquals(2, marks.size());
// const -> ref foo -> subscr expr;
PsiElement src = marks.get("<src>").getParent().getParent();
// ident -> target expr
PsiElement dst = marks.get("<dst>").getParent();
Assert.assertTrue(dst instanceof PyTargetExpression);
PyAssignmentStatement stmt = (PyAssignmentStatement) dst.getParent();
List<Pair<PyExpression, PyExpression>> mapping = stmt.getTargetsToValuesMapping();
Assert.assertEquals(1, mapping.size());
Pair<PyExpression, PyExpression> pair = mapping.get(0);
Assert.assertEquals(dst, pair.getFirst());
Assert.assertEquals(src, pair.getSecond());
}
use of com.jetbrains.python.psi.PyExpression in project intellij-community by JetBrains.
the class PyAssignmentMappingTest method testSubscribedTarget.
public void testSubscribedTarget() throws Exception {
Map<String, PsiElement> marks = loadTest();
Assert.assertEquals(2, marks.size());
// const -> expr;
PsiElement src = marks.get("<src>").getParent();
// ident -> target expr
PsiElement dst = marks.get("<dst>").getParent().getParent();
Assert.assertTrue(dst instanceof PySubscriptionExpression);
PyAssignmentStatement stmt = (PyAssignmentStatement) src.getParent();
List<Pair<PyExpression, PyExpression>> mapping = stmt.getTargetsToValuesMapping();
Assert.assertEquals(1, mapping.size());
Pair<PyExpression, PyExpression> pair = mapping.get(0);
Assert.assertEquals(dst, pair.getFirst());
Assert.assertEquals(src, pair.getSecond());
}
use of com.jetbrains.python.psi.PyExpression in project intellij-community by JetBrains.
the class PyAssignmentMappingTest method testSimple.
public void testSimple() throws Exception {
Map<String, PsiElement> marks = loadTest();
Assert.assertEquals(2, marks.size());
// const -> expr;
PsiElement src = marks.get("<src>").getParent();
// ident -> target expr
PsiElement dst = marks.get("<dst>").getParent();
Assert.assertTrue(dst instanceof PyTargetExpression);
PyAssignmentStatement stmt = (PyAssignmentStatement) dst.getParent();
List<Pair<PyExpression, PyExpression>> mapping = stmt.getTargetsToValuesMapping();
Assert.assertEquals(1, mapping.size());
Pair<PyExpression, PyExpression> pair = mapping.get(0);
Assert.assertEquals(dst, pair.getFirst());
Assert.assertEquals(src, pair.getSecond());
}
Aggregations