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.
16 package com
.intellij
.psi
.impl
.source
.javadoc
;
18 import com
.intellij
.codeInsight
.daemon
.JavaErrorMessages
;
19 import com
.intellij
.lang
.ASTNode
;
20 import com
.intellij
.pom
.java
.LanguageLevel
;
21 import com
.intellij
.psi
.*;
22 import com
.intellij
.psi
.util
.PsiUtil
;
23 import com
.intellij
.psi
.javadoc
.JavadocTagInfo
;
24 import com
.intellij
.psi
.javadoc
.PsiDocTagValue
;
25 import com
.intellij
.util
.ArrayUtil
;
27 import java
.util
.ArrayList
;
28 import java
.util
.Arrays
;
29 import java
.util
.List
;
34 class ParamDocTagInfo
implements JavadocTagInfo
{
35 public String
getName() {
39 public boolean isValidInContext(PsiElement element
) {
40 return element
instanceof PsiMethod
||
41 (element
instanceof PsiClass
&& PsiUtil
.isLanguageLevel5OrHigher(element
));
44 public Object
[] getPossibleValues(PsiElement context
, PsiElement place
, String prefix
) {
45 if (context
instanceof PsiTypeParameterListOwner
) {
46 List
<PsiNamedElement
> result
= new ArrayList
<PsiNamedElement
>(Arrays
.asList(((PsiTypeParameterListOwner
)context
).getTypeParameters()));
48 if ((PsiTypeParameterListOwner
)context
instanceof PsiMethod
) {
49 PsiMethod method
= (PsiMethod
)context
;
50 result
.addAll(Arrays
.asList(method
.getParameterList().getParameters()));
53 return result
.toArray(new PsiNamedElement
[result
.size()]);
56 return ArrayUtil
.EMPTY_OBJECT_ARRAY
;
59 public String
checkTagValue(PsiDocTagValue value
) {
60 if (value
== null) return JavaErrorMessages
.message("javadoc.param.tag.paramter.name.expected");
61 final ASTNode firstChildNode
= value
.getNode().getFirstChildNode();
62 if (firstChildNode
!= null &&
63 firstChildNode
.getElementType().equals(JavaDocTokenType
.DOC_TAG_VALUE_LT
)) {
64 if (value
.getNode().findChildByType(JavaDocTokenType
.DOC_TAG_VALUE_TOKEN
) == null) {
65 return JavaErrorMessages
.message("javadoc.param.tag.type.parameter.name.expected");
68 if (value
.getNode().findChildByType(JavaDocTokenType
.DOC_TAG_VALUE_GT
) == null) {
69 return JavaErrorMessages
.message("javadoc.param.tag.type.parameter.gt.expected");
75 public PsiReference
getReference(PsiDocTagValue value
) {
76 if (value
instanceof PsiDocParamRef
) return value
.getReference();
81 public boolean isInline() {