本文整理汇总了Java中com.jetbrains.python.psi.PyArgumentList类的典型用法代码示例。如果您正苦于以下问题:Java PyArgumentList类的具体用法?Java PyArgumentList怎么用?Java PyArgumentList使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PyArgumentList类属于com.jetbrains.python.psi包,在下文中一共展示了PyArgumentList类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDeclarationRange
import com.jetbrains.python.psi.PyArgumentList; //导入依赖的package包/类
@NotNull
@Override
public TextRange getDeclarationRange(@NotNull PsiElement container) {
int start = container.getTextRange().getStartOffset();
if (container instanceof PyFunction) {
PyParameterList parameterList = ((PyFunction)container).getParameterList();
return new TextRange(start, parameterList.getTextRange().getEndOffset());
}
if (container instanceof PyClass) {
PyArgumentList argumentList = ((PyClass)container).getSuperClassExpressionList();
if (argumentList != null) {
return new TextRange(start, argumentList.getTextRange().getEndOffset());
}
ASTNode nameNode = ((PyClass)container).getNameNode();
if (nameNode != null) {
return new TextRange(start, nameNode.getStartOffset() + nameNode.getTextLength());
}
}
return container.getTextRange();
}
示例2: doApply
import com.jetbrains.python.psi.PyArgumentList; //导入依赖的package包/类
public void doApply(@NotNull Editor editor, @NotNull PySmartEnterProcessor processor, @NotNull PyClass pyClass) throws IncorrectOperationException {
final PsiElement colon = PyPsiUtils.getFirstChildOfType(pyClass, PyTokenTypes.COLON);
if (colon == null) {
final PyArgumentList argList = PsiTreeUtil.getChildOfType(pyClass, PyArgumentList.class);
final int colonOffset = sure(argList).getTextRange().getEndOffset();
String textToInsert = ":";
if (pyClass.getNameNode() == null) {
int newCaretOffset = argList.getTextOffset();
if (argList.getTextLength() == 0) {
newCaretOffset += 1;
textToInsert = " :";
}
processor.registerUnresolvedError(newCaretOffset);
}
editor.getDocument().insertString(colonOffset, textToInsert);
}
}
示例3: visitPyArgumentList
import com.jetbrains.python.psi.PyArgumentList; //导入依赖的package包/类
@Override
public void visitPyArgumentList(PyArgumentList node) {
if (node.getArguments().length > 1) {
for (PyExpression expression : node.getArguments()) {
if (expression instanceof PyGeneratorExpression) {
ASTNode firstChildNode = expression.getNode().getFirstChildNode();
if (firstChildNode.getElementType() != PyTokenTypes.LPAR) {
markError(expression, "Generator expression must be parenthesized if not sole argument");
}
}
}
}
}
示例4: feignCtrlP
import com.jetbrains.python.psi.PyArgumentList; //导入依赖的package包/类
/**
* Imitates pressing of Ctrl+P; fails if results are not as expected.
* @param offset offset of 'cursor' where ^P is pressed.
* @return a {@link Collector} with collected hint info.
* @throws Exception if it fails
*/
private Collector feignCtrlP(int offset) {
Collector collector = new Collector(myFixture.getProject(), myFixture.getFile(), offset);
PyParameterInfoHandler handler = new PyParameterInfoHandler();
final PyArgumentList parameterOwner = handler.findElementForParameterInfo(collector);
collector.setParameterOwner(parameterOwner); // finds arglist, sets items to show
if (collector.getParameterOwner() != null) {
Assert.assertEquals("Collected one analysis result", 1, collector.myItems.length);
handler.updateParameterInfo((PyArgumentList)collector.getParameterOwner(), collector); // moves offset to correct parameter
handler.updateUI((PyCallExpression.PyArgumentsMapping)collector.getItemsToShow()[0], collector); // sets hint text and flags
}
return collector;
}
示例5: testDecoParamCall
import com.jetbrains.python.psi.PyArgumentList; //导入依赖的package包/类
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());
}
示例6: findTarget
import com.jetbrains.python.psi.PyArgumentList; //导入依赖的package包/类
@Nullable
public static Pair<String, PyCallExpression> findTarget(@NotNull PyExpressionStatement statement) {
final PyCallExpression expression = PsiTreeUtil.findChildOfType(statement, PyCallExpression.class);
final PyExpression callee = expression != null ? expression.getCallee() : null;
final PyArgumentList argumentList = expression != null ? expression.getArgumentList() : null;
final PyKeywordArgument nameArgument = argumentList != null ? argumentList.getKeywordArgument("name") : null;
final PyExpression valueExpression = nameArgument != null ? nameArgument.getValueExpression() : null;
if (valueExpression != null && callee != null) {
return Pair.create(unquoteString(valueExpression.getText()), expression);
}
return null;
}
示例7: findTargetDefinitions
import com.jetbrains.python.psi.PyArgumentList; //导入依赖的package包/类
@NotNull
public static Map<String, PyReferenceExpression> findTargetDefinitions(@NotNull PyFile pyFile) {
final PyFunction buildFileAliases = pyFile.findTopLevelFunction("build_file_aliases");
final PyStatement[] statements =
buildFileAliases != null ? buildFileAliases.getStatementList().getStatements() : PyStatement.EMPTY_ARRAY;
final Map<String, PyReferenceExpression> result = new HashMap<>();
for (PyStatement statement : statements) {
if (!(statement instanceof PyReturnStatement)) {
continue;
}
final PyExpression returnExpression = ((PyReturnStatement)statement).getExpression();
if (!(returnExpression instanceof PyCallExpression)) {
continue;
}
final PyArgumentList argumentList = ((PyCallExpression)returnExpression).getArgumentList();
final Collection<PyKeywordArgument> targetDefinitions = PsiTreeUtil.findChildrenOfType(argumentList, PyKeywordArgument.class);
for (PyKeywordArgument targets : targetDefinitions) {
final PyExpression targetsExpression = targets != null ? targets.getValueExpression() : null;
if (targetsExpression instanceof PyDictLiteralExpression) {
for (PyKeyValueExpression keyValueExpression : ((PyDictLiteralExpression)targetsExpression).getElements()) {
final PyExpression keyExpression = keyValueExpression.getKey();
final PyExpression valueExpression = keyValueExpression.getValue();
if (keyExpression instanceof PyStringLiteralExpression) {
result.put(
((PyStringLiteralExpression)keyExpression).getStringValue(),
valueExpression instanceof PyReferenceExpression ? (PyReferenceExpression)valueExpression : null
);
}
}
}
}
}
return result;
}
示例8: PyArgumentListFixer
import com.jetbrains.python.psi.PyArgumentList; //导入依赖的package包/类
public PyArgumentListFixer() {
super(PyArgumentList.class);
}
示例9: canSelect
import com.jetbrains.python.psi.PyArgumentList; //导入依赖的package包/类
@Override
public boolean canSelect(PsiElement e) {
return e instanceof PyListLiteralExpression || e instanceof PyParameterList || e instanceof PyArgumentList;
}
示例10: setParameterOwner
import com.jetbrains.python.psi.PyArgumentList; //导入依赖的package包/类
@Override
public void setParameterOwner(PsiElement o) {
Assert.assertTrue("Found element is a python arglist", o == null || o instanceof PyArgumentList);
myParamOwner = (PyArgumentList)o;
}
示例11: getArgumentList
import com.jetbrains.python.psi.PyArgumentList; //导入依赖的package包/类
@Override
public PyArgumentList getArgumentList() {
return (PyArgumentList) findChildByType(PyxlElementTypes.ARGUMENT_LIST);
}