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
.lang
.groovydoc
.psi
.impl
;
19 import com
.intellij
.lang
.ASTNode
;
20 import com
.intellij
.psi
.PsiElement
;
21 import com
.intellij
.util
.IncorrectOperationException
;
22 import org
.jetbrains
.annotations
.NonNls
;
23 import org
.jetbrains
.annotations
.NotNull
;
24 import org
.jetbrains
.plugins
.groovy
.lang
.groovydoc
.lexer
.GroovyDocTokenTypes
;
25 import org
.jetbrains
.plugins
.groovy
.lang
.groovydoc
.psi
.api
.GrDocComment
;
26 import org
.jetbrains
.plugins
.groovy
.lang
.groovydoc
.psi
.api
.GrDocInlinedTag
;
27 import org
.jetbrains
.plugins
.groovy
.lang
.groovydoc
.psi
.api
.GrDocTagValueToken
;
28 import org
.jetbrains
.plugins
.groovy
.lang
.parser
.GroovyElementTypes
;
29 import org
.jetbrains
.plugins
.groovy
.lang
.psi
.GroovyElementVisitor
;
30 import org
.jetbrains
.plugins
.groovy
.lang
.psi
.GroovyPsiElementFactory
;
32 import java
.util
.List
;
37 public class GrDocInlinedTagImpl
extends GroovyDocPsiElementImpl
implements GrDocInlinedTag
{
39 public GrDocInlinedTagImpl(@NotNull ASTNode node
) {
43 public void accept(GroovyElementVisitor visitor
) {
44 visitor
.visitDocTag(this);
47 public String
toString() {
48 return "GrDocInlinedTag";
52 public String
getName() {
53 return getNameElement().getText();
57 public PsiElement
getNameElement() {
58 PsiElement element
= findChildByType(GroovyDocTokenTypes
.mGDOC_TAG_NAME
);
59 assert element
!= null;
63 public GrDocComment
getContainingComment() {
64 return (GrDocComment
)getParent();
67 public GrDocTagValueToken
getValueElement() {
68 return findChildByClass(GrDocTagValueToken
.class);
71 public PsiElement
[] getDataElements() {
72 final List
<PsiElement
> list
= findChildrenByType(GroovyElementTypes
.mGDOC_COMMENT_DATA
);
73 return list
.toArray(new PsiElement
[list
.size()]);
76 public PsiElement
setName(@NonNls @NotNull String name
) throws IncorrectOperationException
{
77 final PsiElement nameElement
= getNameElement();
78 final GroovyPsiElementFactory factory
= GroovyPsiElementFactory
.getInstance(getProject());
79 final GrDocComment comment
= factory
.createDocCommentFromText("/** {@" + name
+ "}*/");
80 nameElement
.replace(comment
.getTags()[0].getNameElement());