当前位置: 首页>>代码示例>>Java>>正文


Java GrArgumentList.getRightParen方法代码示例

本文整理汇总了Java中org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList.getRightParen方法的典型用法代码示例。如果您正苦于以下问题:Java GrArgumentList.getRightParen方法的具体用法?Java GrArgumentList.getRightParen怎么用?Java GrArgumentList.getRightParen使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList的用法示例。


在下文中一共展示了GrArgumentList.getRightParen方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: processIntention

import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList; //导入方法依赖的package包/类
@Override
protected void processIntention(@NotNull PsiElement element, Project project, Editor editor) throws IncorrectOperationException {
  final GrMethodCallExpression expression = (GrMethodCallExpression) element;
  final StringBuilder newStatementText = new StringBuilder();
  newStatementText.append(expression.getInvokedExpression().getText()).append(' ');
  final GrArgumentList argumentList = expression.getArgumentList();
  if (argumentList != null) {
    final PsiElement leftParen = argumentList.getLeftParen();
    final PsiElement rightParen = argumentList.getRightParen();
    if (leftParen != null) leftParen.delete();
    if (rightParen != null) rightParen.delete();
    newStatementText.append(argumentList.getText());
  }
  final GroovyPsiElementFactory factory = GroovyPsiElementFactory.getInstance(element.getProject());
  final GrStatement newStatement = factory.createStatementFromText(newStatementText.toString());
  expression.replaceWithStatement(newStatement);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:RemoveParenthesesFromMethodCallIntention.java

示例2: convertAppInternal

import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList; //导入方法依赖的package包/类
private static GrMethodCallExpression convertAppInternal(GroovyPsiElementFactory factory, GrApplicationStatement app) {
  final GrCommandArgumentList list = app.getArgumentList();

  final GrMethodCallExpression prototype = (GrMethodCallExpression)factory.createExpressionFromText("foo()");
  prototype.getInvokedExpression().replace(app.getInvokedExpression());
  final GrArgumentList pList = prototype.getArgumentList();
  LOG.assertTrue(pList != null);

  final PsiElement anchor = pList.getRightParen();
  for (GroovyPsiElement arg : list.getAllArguments()) {
    pList.addBefore(arg, anchor);
  }

  return prototype;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:ApplicationStatementUtil.java

示例3: select

import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList; //导入方法依赖的package包/类
@Override
public List<TextRange> select(PsiElement element, CharSequence editorText, int cursorOffset, Editor editor) {
  List<TextRange> result = super.select(element, editorText, cursorOffset, editor);

  if (element instanceof GrArgumentList) {
    GrArgumentList args = ((GrArgumentList) element);
    TextRange range = args.getTextRange();
    if (range.contains(cursorOffset)) {
      PsiElement leftParen = args.getLeftParen();
      PsiElement rightParen = args.getRightParen();

      if (leftParen != null) {
        int leftOffset = leftParen.getTextOffset();
        if (rightParen != null) {
          if (leftOffset + 1 < rightParen.getTextOffset()) {
            int rightOffset = rightParen.getTextRange().getEndOffset();
            range = new TextRange(leftParen.getTextRange().getStartOffset() + 1, rightOffset - 1);
            result.add(range);
          }
        } else {
          range = new TextRange(leftParen.getTextRange().getStartOffset() + 1, element.getTextRange().getEndOffset());
          result.add(range);
        }
      }
    }
  }
  final PsiElement parent = element.getParent();
  if (parent instanceof GrReferenceExpression) {
    final GrArgumentList argumentList = ((GrCall)parent.getParent()).getArgumentList();
    final PsiElement refName = ((GrReferenceExpression)parent).getReferenceNameElement();
    if (argumentList != null && refName == element) {
      result.add(new TextRange(refName.getTextRange().getStartOffset(), argumentList.getTextRange().getEndOffset()));
    }
  }
  return result;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:37,代码来源:GroovyArgListSelectioner.java


注:本文中的org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList.getRightParen方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。