mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-20 13:31:28 +07:00
[java] supports @uses, @provides and @hidden tags in Javadoc inspection
This commit is contained in:
@@ -58,6 +58,7 @@ public class JavaDocLocalInspectionBase extends LocalInspectionTool {
|
||||
}
|
||||
|
||||
protected final Options PACKAGE_OPTIONS = new Options("none", "");
|
||||
protected final Options MODULE_OPTIONS = new Options("none", "");
|
||||
|
||||
public Options TOP_LEVEL_CLASS_OPTIONS = new Options("none", "");
|
||||
public Options INNER_CLASS_OPTIONS = new Options("none", "");
|
||||
@@ -153,6 +154,11 @@ public class JavaDocLocalInspectionBase extends LocalInspectionTool {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitModule(PsiJavaModule module) {
|
||||
checkModule(module, holder, isOnTheFly);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitClass(PsiClass aClass) {
|
||||
checkClass(aClass, holder, isOnTheFly);
|
||||
@@ -191,8 +197,21 @@ public class JavaDocLocalInspectionBase extends LocalInspectionTool {
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isDeprecated(PsiPackage pkg, PsiDocComment docComment) {
|
||||
return PsiImplUtil.isDeprecatedByAnnotation(pkg) || docComment != null && docComment.findTagByName("deprecated") != null;
|
||||
private void checkModule(PsiJavaModule module, ProblemsHolder delegate, boolean isOnTheFly) {
|
||||
PsiDocComment docComment = module.getDocComment();
|
||||
if (IGNORE_DEPRECATED && isDeprecated(module, docComment)) {
|
||||
return;
|
||||
}
|
||||
|
||||
boolean required = JavadocHighlightUtil.isJavaDocRequired(this, module);
|
||||
ProblemHolderImpl holder = new ProblemHolderImpl(delegate, isOnTheFly);
|
||||
|
||||
if (docComment != null) {
|
||||
checkBasics(docComment, docComment.getTags(), module, required, holder);
|
||||
}
|
||||
else if (required) {
|
||||
JavadocHighlightUtil.reportMissingTag(module.getNameIdentifier(), holder);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkClass(PsiClass aClass, ProblemsHolder delegate, boolean isOnTheFly) {
|
||||
@@ -232,8 +251,7 @@ public class JavaDocLocalInspectionBase extends LocalInspectionTool {
|
||||
ProblemHolderImpl holder = new ProblemHolderImpl(delegate, isOnTheFly);
|
||||
|
||||
if (docComment != null) {
|
||||
PsiDocTag[] tags = docComment.getTags();
|
||||
checkBasics(docComment, tags, field, required, holder);
|
||||
checkBasics(docComment, docComment.getTags(), field, required, holder);
|
||||
}
|
||||
else if (required) {
|
||||
JavadocHighlightUtil.reportMissingTag(field.getNameIdentifier(), holder);
|
||||
@@ -311,6 +329,10 @@ public class JavaDocLocalInspectionBase extends LocalInspectionTool {
|
||||
JavadocHighlightUtil.checkDuplicateTags(tags, holder);
|
||||
}
|
||||
|
||||
private static boolean isDeprecated(PsiModifierListOwner element, PsiDocComment docComment) {
|
||||
return PsiImplUtil.isDeprecatedByAnnotation(element) || docComment != null && docComment.findTagByName("deprecated") != null;
|
||||
}
|
||||
|
||||
private boolean isTagRequired(PsiElement context, String tag) {
|
||||
if (context instanceof PsiPackage) {
|
||||
return isTagRequired(PACKAGE_OPTIONS, tag);
|
||||
|
||||
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.codeInspection.javaDoc;
|
||||
|
||||
import com.intellij.codeInspection.InspectionsBundle;
|
||||
@@ -30,6 +16,7 @@ import com.intellij.psi.tree.TokenSet;
|
||||
import com.intellij.psi.util.InheritanceUtil;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.ObjectUtils;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.Nls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -61,12 +48,16 @@ public class JavadocHighlightUtil {
|
||||
}
|
||||
|
||||
static boolean isJavaDocRequired(@NotNull JavaDocLocalInspectionBase inspection, @NotNull PsiModifierListOwner element) {
|
||||
int actualAccess = getAccessNumber(RefJavaUtil.getInstance().getAccessModifier(element));
|
||||
|
||||
if (element instanceof PsiPackage) {
|
||||
return 1 <= getAccessNumber(inspection.PACKAGE_OPTIONS);
|
||||
}
|
||||
|
||||
if (element instanceof PsiJavaModule) {
|
||||
return 1 <= getAccessNumber(inspection.MODULE_OPTIONS);
|
||||
}
|
||||
|
||||
int actualAccess = getAccessNumber(RefJavaUtil.getInstance().getAccessModifier(element));
|
||||
|
||||
if (element instanceof PsiClass) {
|
||||
boolean isInner = PsiTreeUtil.getParentOfType(element, PsiClass.class) != null;
|
||||
return actualAccess <= getAccessNumber(isInner ? inspection.INNER_CLASS_OPTIONS : inspection.TOP_LEVEL_CLASS_OPTIONS);
|
||||
@@ -100,11 +91,11 @@ public class JavadocHighlightUtil {
|
||||
}
|
||||
|
||||
private static int getAccessNumber(String accessModifier) {
|
||||
if (accessModifier.startsWith("none")) return 0;
|
||||
if (accessModifier.startsWith("public")) return 1;
|
||||
if (accessModifier.startsWith("protected")) return 2;
|
||||
if (accessModifier.startsWith("package")) return 3;
|
||||
if (accessModifier.startsWith("private")) return 4;
|
||||
if (accessModifier.startsWith(JavaDocLocalInspectionBase.NONE)) return 0;
|
||||
if (accessModifier.startsWith(JavaDocLocalInspectionBase.PUBLIC)) return 1;
|
||||
if (accessModifier.startsWith(JavaDocLocalInspectionBase.PROTECTED)) return 2;
|
||||
if (accessModifier.startsWith(JavaDocLocalInspectionBase.PACKAGE_LOCAL)) return 3;
|
||||
if (accessModifier.startsWith(JavaDocLocalInspectionBase.PRIVATE)) return 4;
|
||||
|
||||
return 5;
|
||||
}
|
||||
@@ -159,7 +150,7 @@ public class JavadocHighlightUtil {
|
||||
JavadocTagInfo tagInfo = docManager.getTagInfo(tagName);
|
||||
|
||||
if (tagInfo == null || !tagInfo.isValidInContext(context)) {
|
||||
if (checkTagInfo(tag, tagInfo, holder)) continue;
|
||||
if (checkTagInfo(tag, tagName, tagInfo, holder)) continue;
|
||||
}
|
||||
|
||||
PsiDocTagValue value = tag.getValueElement();
|
||||
@@ -178,14 +169,8 @@ public class JavadocHighlightUtil {
|
||||
}
|
||||
|
||||
if (message != null) {
|
||||
PsiDocTagValue valueElement = tag.getValueElement();
|
||||
if (valueElement == null) {
|
||||
String tagText = "<code>" + tag.getName() + "</code>";
|
||||
holder.problem(tag, InspectionsBundle.message("inspection.javadoc.method.problem.missing.tag.description", tagText), null);
|
||||
}
|
||||
else {
|
||||
holder.problem(valueElement, message, null);
|
||||
}
|
||||
PsiElement toHighlight = ObjectUtils.notNull(tag.getValueElement(), tag.getNameElement());
|
||||
holder.problem(toHighlight, message, null);
|
||||
}
|
||||
|
||||
PsiElement[] dataElements = tag.getDataElements();
|
||||
@@ -219,8 +204,9 @@ public class JavadocHighlightUtil {
|
||||
for (PsiElement element : elements) {
|
||||
if (element instanceof PsiInlineDocTag) {
|
||||
PsiInlineDocTag tag = (PsiInlineDocTag)element;
|
||||
if (docManager.getTagInfo(tag.getName()) == null) {
|
||||
checkTagInfo(tag, null, holder);
|
||||
String tagName = tag.getName();
|
||||
if (docManager.getTagInfo(tagName) == null) {
|
||||
checkTagInfo(tag, tagName, null, holder);
|
||||
}
|
||||
if (!holder.inspection().IGNORE_POINT_TO_ITSELF) {
|
||||
PsiDocTagValue value = tag.getValueElement();
|
||||
@@ -244,9 +230,7 @@ public class JavadocHighlightUtil {
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean checkTagInfo(PsiDocTag tag, JavadocTagInfo tagInfo, ProblemHolder holder) {
|
||||
String tagName = tag.getName();
|
||||
|
||||
private static boolean checkTagInfo(PsiDocTag tag, String tagName, JavadocTagInfo tagInfo, ProblemHolder holder) {
|
||||
StringTokenizer tokenizer = new StringTokenizer(holder.inspection().myAdditionalJavadocTags, ", ");
|
||||
while (tokenizer.hasMoreTokens()) {
|
||||
if (Comparing.strEqual(tagName, tokenizer.nextToken())) return true;
|
||||
|
||||
@@ -95,6 +95,8 @@ public class JavaDocLocalInspection extends JavaDocLocalInspectionBase {
|
||||
String[] tags = {"@author", "@version", "@since"};
|
||||
tabs.add(InspectionsBundle.message("inspection.javadoc.option.tab.title.package"),
|
||||
createOptionsPanel(new String[]{NONE, PUBLIC}, tags, PACKAGE_OPTIONS));
|
||||
tabs.add(InspectionsBundle.message("inspection.javadoc.option.tab.title.module"),
|
||||
createOptionsPanel(new String[]{NONE, PUBLIC}, tags, MODULE_OPTIONS));
|
||||
tags = new String[]{"@author", "@version", "@since", "@param"};
|
||||
tabs.add(InspectionsBundle.message("inspection.javadoc.option.tab.title"),
|
||||
createOptionsPanel(new String[]{NONE, PUBLIC, PACKAGE_LOCAL}, tags, TOP_LEVEL_CLASS_OPTIONS));
|
||||
@@ -116,15 +118,15 @@ public class JavaDocLocalInspection extends JavaDocLocalInspectionBase {
|
||||
periodCheckBox.addActionListener(e -> IGNORE_JAVADOC_PERIOD = periodCheckBox.isSelected());
|
||||
add(periodCheckBox, gc);
|
||||
|
||||
JCheckBox ignoreDuplicateThrowsCheckBox = new JCheckBox("Ignore duplicate throws tag", isIgnoreDuplicatedThrows());
|
||||
JCheckBox ignoreDuplicateThrowsCheckBox = new JCheckBox(InspectionsBundle.message("inspection.javadoc.option.ignore.throws"), isIgnoreDuplicatedThrows());
|
||||
ignoreDuplicateThrowsCheckBox.addActionListener(e -> setIgnoreDuplicatedThrows(ignoreDuplicateThrowsCheckBox.isSelected()));
|
||||
add(ignoreDuplicateThrowsCheckBox, gc);
|
||||
|
||||
JCheckBox ignorePointToItselfCheckBox = new JCheckBox("Ignore javadoc pointing to itself", IGNORE_POINT_TO_ITSELF);
|
||||
JCheckBox ignorePointToItselfCheckBox = new JCheckBox(InspectionsBundle.message("inspection.javadoc.option.ignore.self.ref"), IGNORE_POINT_TO_ITSELF);
|
||||
ignorePointToItselfCheckBox.addActionListener(e -> IGNORE_POINT_TO_ITSELF = ignorePointToItselfCheckBox.isSelected());
|
||||
add(ignorePointToItselfCheckBox, gc);
|
||||
|
||||
JCheckBox ignoreSimpleAccessorsCheckBox = new JCheckBox("Ignore simple property accessors", isIgnoreSimpleAccessors());
|
||||
JCheckBox ignoreSimpleAccessorsCheckBox = new JCheckBox(InspectionsBundle.message("inspection.javadoc.option.ignore.simple"), isIgnoreSimpleAccessors());
|
||||
ignoreSimpleAccessorsCheckBox.addActionListener(e -> setIgnoreSimpleAccessors(ignoreSimpleAccessorsCheckBox.isSelected()));
|
||||
add(ignoreSimpleAccessorsCheckBox, gc);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.psi.impl.source.javadoc;
|
||||
|
||||
import com.intellij.codeInsight.daemon.JavaErrorMessages;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiJavaCodeReferenceElement;
|
||||
import com.intellij.psi.PsiReference;
|
||||
import com.intellij.psi.javadoc.JavadocTagInfo;
|
||||
import com.intellij.psi.javadoc.PsiDocTagValue;
|
||||
|
||||
abstract class ClassReferenceTagInfo implements JavadocTagInfo {
|
||||
private final String myName;
|
||||
|
||||
public ClassReferenceTagInfo(String name) {
|
||||
myName = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return myName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInline() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String checkTagValue(PsiDocTagValue value) {
|
||||
PsiElement refHolder = value != null ? value.getFirstChild() : null;
|
||||
if (refHolder == null) {
|
||||
return JavaErrorMessages.message("javadoc.ref.tag.class.ref.expected");
|
||||
}
|
||||
|
||||
PsiElement refElement = refHolder.getFirstChild();
|
||||
if (!(refElement instanceof PsiJavaCodeReferenceElement)) {
|
||||
return JavaErrorMessages.message("javadoc.exception.tag.wrong.tag.value");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiReference getReference(PsiDocTagValue value) {
|
||||
return null;
|
||||
}
|
||||
|
||||
protected static PsiClass resolveClass(PsiDocTagValue value) {
|
||||
PsiElement refHolder = value.getFirstChild();
|
||||
if (refHolder != null) {
|
||||
PsiElement refElement = refHolder.getFirstChild();
|
||||
if (refElement instanceof PsiJavaCodeReferenceElement) {
|
||||
PsiElement target = ((PsiJavaCodeReferenceElement)refElement).resolve();
|
||||
if (target instanceof PsiClass) {
|
||||
return (PsiClass)target;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,111 +1,57 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.psi.impl.source.javadoc;
|
||||
|
||||
import com.intellij.codeInsight.daemon.JavaErrorMessages;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.javadoc.JavadocTagInfo;
|
||||
import com.intellij.psi.javadoc.PsiDocTagValue;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
/**
|
||||
* @author mike
|
||||
*/
|
||||
class ExceptionTagInfo implements JavadocTagInfo {
|
||||
private final String myName;
|
||||
|
||||
public ExceptionTagInfo(@NonNls String name) {
|
||||
myName = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return myName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInline() {
|
||||
return false;
|
||||
class ExceptionTagInfo extends ClassReferenceTagInfo {
|
||||
public ExceptionTagInfo(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidInContext(PsiElement element) {
|
||||
if (!(element instanceof PsiMethod)) return false;
|
||||
return true;
|
||||
return element instanceof PsiMethod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String checkTagValue(PsiDocTagValue value) {
|
||||
if (value == null) return JavaErrorMessages.message("javadoc.exception.tag.exception.class.expected");
|
||||
final PsiElement firstChild = value.getFirstChild();
|
||||
if (firstChild == null) return JavaErrorMessages.message("javadoc.exception.tag.exception.class.expected");
|
||||
String result = super.checkTagValue(value);
|
||||
if (result != null) return result;
|
||||
|
||||
final PsiElement psiElement = firstChild.getFirstChild();
|
||||
if (!(psiElement instanceof PsiJavaCodeReferenceElement)) {
|
||||
return JavaErrorMessages.message("javadoc.exception.tag.wrong.tag.value");
|
||||
PsiClass exceptionClass = resolveClass(value);
|
||||
if (exceptionClass == null) return null;
|
||||
|
||||
PsiClass throwable = JavaPsiFacade.getInstance(value.getProject()).findClass(CommonClassNames.JAVA_LANG_THROWABLE, value.getResolveScope());
|
||||
if (throwable != null && !exceptionClass.equals(throwable) && !exceptionClass.isInheritor(throwable, true)) {
|
||||
return JavaErrorMessages.message("javadoc.exception.tag.class.is.not.throwable", exceptionClass.getQualifiedName());
|
||||
}
|
||||
|
||||
final PsiJavaCodeReferenceElement ref = ((PsiJavaCodeReferenceElement)psiElement);
|
||||
final PsiElement element = ref.resolve();
|
||||
if (!(element instanceof PsiClass)) return null;
|
||||
|
||||
final PsiClass exceptionClass = (PsiClass)element;
|
||||
|
||||
|
||||
final PsiClass throwable = JavaPsiFacade.getInstance(value.getProject()).findClass("java.lang.Throwable", value.getResolveScope());
|
||||
|
||||
if (throwable != null) {
|
||||
if (!exceptionClass.equals(throwable) && !exceptionClass.isInheritor(throwable, true)) {
|
||||
return JavaErrorMessages.message("javadoc.exception.tag.class.is.not.throwable", exceptionClass.getQualifiedName());
|
||||
}
|
||||
}
|
||||
|
||||
final PsiClass runtimeException =
|
||||
JavaPsiFacade.getInstance(value.getProject()).findClass("java.lang.RuntimeException", value.getResolveScope());
|
||||
|
||||
if (runtimeException != null &&
|
||||
(exceptionClass.isInheritor(runtimeException, true) || exceptionClass.equals(runtimeException))) {
|
||||
PsiClass runtimeException = JavaPsiFacade.getInstance(value.getProject()).findClass(CommonClassNames.JAVA_LANG_RUNTIME_EXCEPTION, value.getResolveScope());
|
||||
if (runtimeException != null && (exceptionClass.isInheritor(runtimeException, true) || exceptionClass.equals(runtimeException))) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final PsiClass errorException = JavaPsiFacade.getInstance(value.getProject()).findClass("java.lang.Error", value.getResolveScope());
|
||||
|
||||
if (errorException != null &&
|
||||
(exceptionClass.isInheritor(errorException, true) || exceptionClass.equals(errorException))) {
|
||||
PsiClass errorException = JavaPsiFacade.getInstance(value.getProject()).findClass(CommonClassNames.JAVA_LANG_ERROR, value.getResolveScope());
|
||||
if (errorException != null && (exceptionClass.isInheritor(errorException, true) || exceptionClass.equals(errorException))) {
|
||||
return null;
|
||||
}
|
||||
|
||||
PsiMethod method = PsiTreeUtil.getParentOfType(value, PsiMethod.class);
|
||||
if (method == null) {
|
||||
return null;
|
||||
}
|
||||
final PsiClassType[] references = method.getThrowsList().getReferencedTypes();
|
||||
if (method == null) return null;
|
||||
|
||||
for (PsiClassType reference : references) {
|
||||
final PsiClass psiClass = reference.resolve();
|
||||
if (psiClass == null) continue;
|
||||
if (exceptionClass.isInheritor(psiClass, true) || exceptionClass.equals(psiClass)) return null;
|
||||
for (PsiClassType reference : method.getThrowsList().getReferencedTypes()) {
|
||||
PsiClass psiClass = reference.resolve();
|
||||
if (psiClass != null && (exceptionClass.isInheritor(psiClass, true) || exceptionClass.equals(psiClass))) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return JavaErrorMessages.message("javadoc.exception.tag.exception.is.not.thrown", exceptionClass.getName(), method.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiReference getReference(PsiDocTagValue value) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.psi.impl.source.javadoc;
|
||||
|
||||
import com.intellij.codeInspection.SuppressionUtilCore;
|
||||
@@ -32,6 +18,7 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
* @author mike
|
||||
* @see <a href="https://docs.oracle.com/javase/9/docs/specs/doc-comment-spec.html">Documentation Comment Specification</a>
|
||||
*/
|
||||
public class JavadocManagerImpl implements JavadocManager {
|
||||
private final List<JavadocTagInfo> myInfos;
|
||||
@@ -48,6 +35,7 @@ public class JavadocManagerImpl implements JavadocManager {
|
||||
myInfos.add(new SimpleDocTagInfo("apiNote", LanguageLevel.JDK_1_8, false, PsiElement.class));
|
||||
myInfos.add(new SimpleDocTagInfo("implNote", LanguageLevel.JDK_1_8, false, PsiElement.class));
|
||||
myInfos.add(new SimpleDocTagInfo("implSpec", LanguageLevel.JDK_1_8, false, PsiElement.class));
|
||||
myInfos.add(new SimpleDocTagInfo("hidden", LanguageLevel.JDK_1_9, false, PsiElement.class));
|
||||
|
||||
myInfos.add(new SimpleDocTagInfo("docRoot", LanguageLevel.JDK_1_3, true, PsiElement.class));
|
||||
myInfos.add(new SimpleDocTagInfo("inheritDoc", LanguageLevel.JDK_1_4, true, PsiElement.class));
|
||||
@@ -66,6 +54,8 @@ public class JavadocManagerImpl implements JavadocManager {
|
||||
myInfos.add(new SeeDocTagInfo("linkplain", true));
|
||||
myInfos.add(new ExceptionTagInfo("exception"));
|
||||
myInfos.add(new ExceptionTagInfo("throws"));
|
||||
myInfos.add(new ServiceReferenceTagInfo("provides"));
|
||||
myInfos.add(new ServiceReferenceTagInfo("uses"));
|
||||
myInfos.add(new ValueDocTagInfo());
|
||||
|
||||
Collections.addAll(myInfos, Extensions.getExtensions(JavadocTagInfo.EP_NAME, project));
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.psi.impl.source.javadoc;
|
||||
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiJavaModule;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
|
||||
public class ServiceReferenceTagInfo extends ClassReferenceTagInfo {
|
||||
public ServiceReferenceTagInfo(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidInContext(PsiElement element) {
|
||||
return element instanceof PsiJavaModule && PsiUtil.getLanguageLevel(element).isAtLeast(LanguageLevel.JDK_1_9);
|
||||
}
|
||||
}
|
||||
@@ -323,7 +323,7 @@ illegal.underscore=Illegal underscore
|
||||
|
||||
import.statement.identifier.or.asterisk.expected.=Identifier or '*' expected
|
||||
|
||||
javadoc.exception.tag.exception.class.expected=Exception class expected
|
||||
javadoc.ref.tag.class.ref.expected=Class reference expected
|
||||
javadoc.exception.tag.wrong.tag.value=Wrong tag value
|
||||
javadoc.exception.tag.class.is.not.throwable=Class {0} is not a descendant of Throwable
|
||||
javadoc.exception.tag.exception.is.not.thrown={0} is not declared to be thrown by method {1}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
class Test {
|
||||
/**
|
||||
* <warning descr="'throws' tag description is missing">@throws</warning>
|
||||
*/
|
||||
public void foo() {}
|
||||
|
||||
class SomeClass {}
|
||||
/**
|
||||
* <warning descr="'throws' tag description is missing"><warning descr="Class reference expected">@throws</warning></warning>
|
||||
*/
|
||||
public void foo() {}
|
||||
}
|
||||
@@ -1,6 +1,12 @@
|
||||
/**
|
||||
* <warning descr="Tag 'provides' is not allowed here">@provides</warning> Test
|
||||
* <warning descr="Tag 'uses' is not allowed here">@uses</warning> Test
|
||||
*/
|
||||
class Test {
|
||||
/**
|
||||
* Quote: Tagging is achieved using {@index ulps}.
|
||||
*
|
||||
* @hidden
|
||||
*/
|
||||
public void i() {}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
class Test {
|
||||
/**
|
||||
* <warning descr="'param' tag description is missing">@param</warning>
|
||||
* <warning descr="Parameter name expected">@param</warning>
|
||||
*/
|
||||
public void foo() {
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
/**
|
||||
* A module.
|
||||
*
|
||||
* <warning descr="Class reference expected">@uses</warning>
|
||||
* <warning descr="Class reference expected">@provides</warning>
|
||||
* @uses java.lang.String for greater good
|
||||
* @provides java.lang.Number for your delight
|
||||
*/
|
||||
module M1 { }
|
||||
@@ -0,0 +1,5 @@
|
||||
/**
|
||||
* @uses
|
||||
*/
|
||||
@Deprecated
|
||||
module M2 { }
|
||||
@@ -6,10 +6,12 @@ import com.intellij.codeInsight.daemon.LightDaemonAnalyzerTestCase;
|
||||
import com.intellij.codeInspection.javaDoc.JavaDocLocalInspection;
|
||||
import com.intellij.codeInspection.javaDoc.JavaDocReferenceInspection;
|
||||
import com.intellij.openapi.paths.WebReference;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.vcs.IssueNavigationConfiguration;
|
||||
import com.intellij.openapi.vcs.IssueNavigationLink;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.PsiReferenceBase;
|
||||
import com.intellij.testFramework.IdeaTestUtil;
|
||||
import com.intellij.testFramework.PlatformTestUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -31,6 +33,11 @@ public class JavadocHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
enableInspectionTools(myInspection, new JavaDocReferenceInspection());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Sdk getProjectJDK() {
|
||||
return IdeaTestUtil.getMockJdk9();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected String getTestDataPath() {
|
||||
@@ -78,6 +85,8 @@ public class JavadocHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
public void testPackageInfo4() { doTest("packageInfo/p4/package-info.java"); }
|
||||
public void testJava18Tags() { doTest(); }
|
||||
public void testJava19Tags() { setLanguageLevel(LanguageLevel.JDK_1_9); doTest(); }
|
||||
public void testModuleInfoTags() { setLanguageLevel(LanguageLevel.JDK_1_9); doTest("moduleInfo/m1/module-info.java"); }
|
||||
public void testDeprecatedModule() { setLanguageLevel(LanguageLevel.JDK_1_9); doTest("moduleInfo/m2/module-info.java"); }
|
||||
public void testUnknownInlineTag() { doTest(); }
|
||||
public void testUnknownTags() { doTest(); }
|
||||
public void testBadCharacters() { doTest(); }
|
||||
|
||||
@@ -289,12 +289,16 @@ inspection.javadoc.display.name=Declaration has Javadoc problems
|
||||
inspection.javadoc.ref.display.name=Declaration has problems in Javadoc references
|
||||
inspection.javadoc.lint.display.name=HTML problems in Javadoc (DocLint)
|
||||
inspection.javadoc.option.tab.title.package=Package
|
||||
inspection.javadoc.option.tab.title.module=Module
|
||||
inspection.javadoc.option.tab.title=Class
|
||||
inspection.javadoc.option.tab.title.method=Method
|
||||
inspection.javadoc.option.tab.title.field=Field
|
||||
inspection.javadoc.option.tab.title.inner.class=Inner class
|
||||
inspection.javadoc.option.ignore.deprecated=Ignore elements marked as @deprecated
|
||||
inspection.javadoc.option.ignore.period=Ignore period problems
|
||||
inspection.javadoc.option.ignore.throws=Ignore duplicate 'throws' tag
|
||||
inspection.javadoc.option.ignore.self.ref=Ignore Javadoc pointing to itself
|
||||
inspection.javadoc.option.ignore.simple=Ignore simple property accessors
|
||||
|
||||
inspection.scope.for.title=Scope
|
||||
|
||||
|
||||
Reference in New Issue
Block a user