• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java PyArgumentList类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:PyDeclarationRangeHandler.java


示例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);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:PyClassFixer.java


示例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");
        }
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:GeneratorInArgumentListAnnotator.java


示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:PyParameterInfoTest.java


示例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());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:PyDecoratorTest.java


示例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;
}
 
开发者ID:pantsbuild,项目名称:intellij-pants-plugin,代码行数:13,代码来源:PantsPsiUtil.java


示例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;
}
 
开发者ID:pantsbuild,项目名称:intellij-pants-plugin,代码行数:35,代码来源:PantsPsiUtil.java


示例8: PyArgumentListFixer

import com.jetbrains.python.psi.PyArgumentList; //导入依赖的package包/类
public PyArgumentListFixer() {
  super(PyArgumentList.class);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:4,代码来源:PyArgumentListFixer.java


示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:PyListSelectionHandler.java


示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:6,代码来源:PyParameterInfoTest.java


示例11: getArgumentList

import com.jetbrains.python.psi.PyArgumentList; //导入依赖的package包/类
@Override
public PyArgumentList getArgumentList() {
    return (PyArgumentList) findChildByType(PyxlElementTypes.ARGUMENT_LIST);
}
 
开发者ID:christoffer,项目名称:pycharm-pyxl,代码行数:5,代码来源:PyxlTag.java



注:本文中的com.jetbrains.python.psi.PyArgumentList类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java VersionChangerFactory类代码示例发布时间:2022-05-16
下一篇:
Java AlertLevelParser类代码示例发布时间:2022-05-16
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap