cf2d621c3d9736ede2a07a86e2a799a051cde340
2 * Copyright 2000-2009 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org
.jetbrains
.plugins
.groovy
.editor
.selection
;
19 import com
.intellij
.psi
.PsiElement
;
20 import com
.intellij
.openapi
.util
.TextRange
;
21 import com
.intellij
.openapi
.editor
.Editor
;
22 import org
.jetbrains
.plugins
.groovy
.lang
.groovydoc
.psi
.api
.GrDocMethodParams
;
23 import org
.jetbrains
.plugins
.groovy
.lang
.psi
.api
.statements
.arguments
.GrArgumentList
;
25 import java
.util
.List
;
30 public class GroovyArgListSelectioner
extends GroovyBasicSelectioner
{
31 public boolean canSelect(PsiElement e
) {
32 return e
instanceof GrArgumentList
;
35 public List
<TextRange
> select(PsiElement element
, CharSequence editorText
, int cursorOffset
, Editor editor
) {
36 List
<TextRange
> result
= super.select(element
, editorText
, cursorOffset
, editor
);
38 if (element
instanceof GrArgumentList
) {
39 GrArgumentList args
= ((GrArgumentList
) element
);
40 TextRange range
= args
.getTextRange();
41 if (range
.contains(cursorOffset
)) {
42 PsiElement leftParen
= args
.getLeftParen();
43 PsiElement rightParen
= args
.getRightParen();
45 if (leftParen
!= null) {
46 int leftOffset
= leftParen
.getTextOffset();
47 if (rightParen
!= null) {
48 if (leftOffset
+ 1 < rightParen
.getTextOffset()) {
49 int rightOffset
= rightParen
.getTextRange().getEndOffset();
50 range
= new TextRange(leftParen
.getTextRange().getStartOffset() + 1, rightOffset
- 1);
54 range
= new TextRange(leftParen
.getTextRange().getStartOffset() + 1, element
.getTextRange().getEndOffset());