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
.openapi
.extensions
.Extensions
;
19 import com
.intellij
.openapi
.project
.Project
;
20 import com
.intellij
.pom
.java
.LanguageLevel
;
21 import com
.intellij
.psi
.PsiClass
;
22 import com
.intellij
.psi
.PsiElement
;
23 import com
.intellij
.psi
.PsiField
;
24 import com
.intellij
.psi
.PsiMethod
;
25 import com
.intellij
.psi
.formatter
.FormatterUtil
;
26 import com
.intellij
.psi
.formatter
.JavadocFormatterUtilHlper
;
27 import com
.intellij
.psi
.javadoc
.JavadocManager
;
28 import com
.intellij
.psi
.javadoc
.JavadocTagInfo
;
29 import org
.jetbrains
.annotations
.NotNull
;
30 import org
.jetbrains
.annotations
.Nullable
;
32 import java
.util
.ArrayList
;
33 import java
.util
.Collections
;
34 import java
.util
.List
;
39 public class JavadocManagerImpl
implements JavadocManager
{
40 private final List
<JavadocTagInfo
> myInfos
;
43 FormatterUtil
.addHelper(new JavadocFormatterUtilHlper());
46 public JavadocManagerImpl(Project project
) {
47 myInfos
= new ArrayList
<JavadocTagInfo
>();
49 myInfos
.add(new SimpleDocTagInfo("author", PsiClass
.class, false, LanguageLevel
.JDK_1_3
));
50 myInfos
.add(new SimpleDocTagInfo("deprecated", PsiElement
.class, false, LanguageLevel
.JDK_1_3
));
51 myInfos
.add(new SimpleDocTagInfo("serialData", PsiMethod
.class, false, LanguageLevel
.JDK_1_3
));
52 myInfos
.add(new SimpleDocTagInfo("serialField", PsiField
.class, false, LanguageLevel
.JDK_1_3
));
53 myInfos
.add(new SimpleDocTagInfo("since", PsiElement
.class, false, LanguageLevel
.JDK_1_3
));
54 myInfos
.add(new SimpleDocTagInfo("version", PsiClass
.class, false, LanguageLevel
.JDK_1_3
));
56 myInfos
.add(new SimpleDocTagInfo("docRoot", PsiElement
.class, true, LanguageLevel
.JDK_1_3
));
57 myInfos
.add(new SimpleDocTagInfo("inheritDoc", PsiElement
.class, true, LanguageLevel
.JDK_1_4
));
58 myInfos
.add(new SimpleDocTagInfo("literal", PsiElement
.class, true, LanguageLevel
.JDK_1_5
));
59 myInfos
.add(new SimpleDocTagInfo("code", PsiElement
.class, true, LanguageLevel
.JDK_1_5
));
61 //Not a standard tag, but added by IDEA for inspection suppression
62 myInfos
.add(new SimpleDocTagInfo("noinspection", PsiElement
.class, false, LanguageLevel
.JDK_1_3
));
64 myInfos
.add(new ParamDocTagInfo());
65 myInfos
.add(new ReturnDocTagInfo());
66 myInfos
.add(new SerialDocTagInfo());
67 myInfos
.add(new SeeDocTagInfo("see", false));
68 myInfos
.add(new SeeDocTagInfo("link", true));
69 myInfos
.add(new SeeDocTagInfo("linkplain", true));
70 myInfos
.add(new ExceptionTagInfo("exception"));
71 myInfos
.add(new ExceptionTagInfo("throws"));
72 myInfos
.add(new ValueDocTagInfo());
73 Collections
.addAll(myInfos
, Extensions
.getExtensions(JavadocTagInfo
.EP_NAME
, project
));
77 public void registerTagInfo(@NotNull JavadocTagInfo info
) {
82 public JavadocTagInfo
[] getTagInfos(PsiElement context
) {
83 List
<JavadocTagInfo
> result
= new ArrayList
<JavadocTagInfo
>();
85 for (JavadocTagInfo info
: myInfos
) {
86 if (info
.isValidInContext(context
)) {
91 return result
.toArray(new JavadocTagInfo
[result
.size()]);
95 public JavadocTagInfo
getTagInfo(String name
) {
96 for (JavadocTagInfo info
: myInfos
) {
97 if (info
.getName().equals(name
)) return info
;