本文整理匯總了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;
}
示例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;
}