diff --git a/java/java-psi-api/src/com/intellij/psi/javadoc/CustomJavadocTagProvider.java b/java/java-psi-api/src/com/intellij/psi/javadoc/CustomJavadocTagProvider.java new file mode 100644 index 000000000000..c6a4ca4b07e3 --- /dev/null +++ b/java/java-psi-api/src/com/intellij/psi/javadoc/CustomJavadocTagProvider.java @@ -0,0 +1,51 @@ +/* + * Copyright 2000-2015 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. + */ +package com.intellij.psi.javadoc; + +import com.intellij.openapi.extensions.ExtensionPointName; + +import java.util.List; + +public interface CustomJavadocTagProvider { + + ExtensionPointName EP_NAME = ExtensionPointName.create( + "com.intellij.customJavadocTagProvider"); + + List getSupportedTags(); + +} + + + + + + + + + + + + + + + + + + + + + + diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/javadoc/JavadocManagerImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/javadoc/JavadocManagerImpl.java index 882e6b68498f..1fd12fd8d55a 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/javadoc/JavadocManagerImpl.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/javadoc/JavadocManagerImpl.java @@ -20,6 +20,7 @@ import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.project.Project; import com.intellij.pom.java.LanguageLevel; import com.intellij.psi.*; +import com.intellij.psi.javadoc.CustomJavadocTagProvider; import com.intellij.psi.javadoc.JavadocManager; import com.intellij.psi.javadoc.JavadocTagInfo; import org.jetbrains.annotations.NotNull; @@ -65,7 +66,11 @@ public class JavadocManagerImpl implements JavadocManager { myInfos.add(new ExceptionTagInfo("exception")); myInfos.add(new ExceptionTagInfo("throws")); myInfos.add(new ValueDocTagInfo()); + Collections.addAll(myInfos, Extensions.getExtensions(JavadocTagInfo.EP_NAME, project)); + for (CustomJavadocTagProvider extension : Extensions.getExtensions(CustomJavadocTagProvider.EP_NAME)) { + myInfos.addAll(extension.getSupportedTags()); + } } @Deprecated diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/javadoc/MojoClassAnnotationTagProvider.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/javadoc/MojoClassAnnotationTagProvider.java new file mode 100644 index 000000000000..545fb6e99788 --- /dev/null +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/javadoc/MojoClassAnnotationTagProvider.java @@ -0,0 +1,119 @@ +/* + * Copyright 2000-2015 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. + */ +package org.jetbrains.idea.maven.javadoc;/* + * Copyright 2000-2015 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. + */ + +import com.intellij.psi.PsiClass; +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiReference; +import com.intellij.psi.javadoc.CustomJavadocTagProvider; +import com.intellij.psi.javadoc.JavadocTagInfo; +import com.intellij.psi.javadoc.PsiDocTagValue; +import com.intellij.psi.util.InheritanceUtil; +import com.intellij.util.Function; +import com.intellij.util.containers.ContainerUtil; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.List; + +public class MojoClassAnnotationTagProvider implements CustomJavadocTagProvider { + + private static final String[] ANNOTATION_NAMES = { + "goal", + "requiresDependencyResolution", + "requiresProject", + "requiresReports", + "aggregator", + "requiresOnline", + "requiresDirectInvocation", + "phase", + "execute" + }; + + @Override + public List getSupportedTags() { + return ContainerUtil.map(ANNOTATION_NAMES, new Function() { + @Override + public JavadocTagInfo fun(String name) { + return new MojoAnnotationInfo(name); + } + }); + } + +} + +class MojoAnnotationInfo implements JavadocTagInfo { + + private static final String BASE_CLASS = "org.apache.maven.plugin.Mojo"; + private final String myName; + + public MojoAnnotationInfo(@NotNull String name) { + myName = name; + } + + @Override + public String getName() { + return myName; + } + + @Override + public boolean isInline() { + return false; + } + + @Override + public boolean isValidInContext(PsiElement element) { + if (element instanceof PsiClass) { + PsiClass psiClass = (PsiClass)element; + return InheritanceUtil.isInheritor(psiClass, BASE_CLASS); + } + return false; + } + + @Override + public Object[] getPossibleValues(PsiElement context, PsiElement place, String prefix) { + return null; + } + + @Nullable + @Override + public String checkTagValue(PsiDocTagValue value) { + return null; + } + + @Nullable + @Override + public PsiReference getReference(PsiDocTagValue value) { + return null; + } +} + + + diff --git a/plugins/maven/src/main/resources/META-INF/plugin.xml b/plugins/maven/src/main/resources/META-INF/plugin.xml index 310e996322e1..e477a5cac35a 100644 --- a/plugins/maven/src/main/resources/META-INF/plugin.xml +++ b/plugins/maven/src/main/resources/META-INF/plugin.xml @@ -34,6 +34,7 @@ org.intellij.groovy + diff --git a/plugins/maven/src/test/data/inspections/javadocMojoValidTags/expected.xml b/plugins/maven/src/test/data/inspections/javadocMojoValidTags/expected.xml new file mode 100644 index 000000000000..4fca6818f97d --- /dev/null +++ b/plugins/maven/src/test/data/inspections/javadocMojoValidTags/expected.xml @@ -0,0 +1,8 @@ + + + + TestMojo.java + 13 + Wrong tag <code>ololo</code> + + \ No newline at end of file diff --git a/plugins/maven/src/test/data/inspections/javadocMojoValidTags/src/TestMojo.java b/plugins/maven/src/test/data/inspections/javadocMojoValidTags/src/TestMojo.java new file mode 100644 index 000000000000..cbe31395ce35 --- /dev/null +++ b/plugins/maven/src/test/data/inspections/javadocMojoValidTags/src/TestMojo.java @@ -0,0 +1,19 @@ +package org.apache.maven.plugin; + +/** + * @goal + * @requiresDependencyResolution + * @requiresProject + * @requiresReports + * @aggregator + * @requiresOnline + * @requiresDirectInvocation + * @phase + * @execute + * @ololo + */ +class TestMojo implements Mojo { +} + +interface Mojo { +} \ No newline at end of file diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/inspections/MojoAnnotationInJavadocTest.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/inspections/MojoAnnotationInJavadocTest.java new file mode 100644 index 000000000000..436b948a4f99 --- /dev/null +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/inspections/MojoAnnotationInJavadocTest.java @@ -0,0 +1,32 @@ +/* + * Copyright 2000-2015 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. + */ +package org.jetbrains.idea.maven.inspections; + +import com.intellij.codeInspection.javaDoc.JavaDocLocalInspection; +import com.intellij.openapi.application.PluginPathManager; +import com.intellij.testFramework.InspectionTestCase; + +public class MojoAnnotationInJavadocTest extends InspectionTestCase { + + @Override + protected String getTestDataPath() { + return PluginPathManager.getPluginHomePath("maven") + "/src/test/data/inspections"; + } + + public void testJavadocMojoValidTags() throws Exception { + doTest(getTestName(true), new JavaDocLocalInspection()); + } +} diff --git a/resources/src/META-INF/IdeaPlugin.xml b/resources/src/META-INF/IdeaPlugin.xml index b59283f0fa5e..c1053917bc37 100644 --- a/resources/src/META-INF/IdeaPlugin.xml +++ b/resources/src/META-INF/IdeaPlugin.xml @@ -188,6 +188,7 @@ +