diff options
Diffstat (limited to 'java/java-impl/src/com/intellij/psi/impl')
9 files changed, 0 insertions, 774 deletions
diff --git a/java/java-impl/src/com/intellij/psi/impl/source/javadoc/ExceptionTagInfo.java b/java/java-impl/src/com/intellij/psi/impl/source/javadoc/ExceptionTagInfo.java deleted file mode 100644 index 4986258f0697..000000000000 --- a/java/java-impl/src/com/intellij/psi/impl/source/javadoc/ExceptionTagInfo.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright 2000-2009 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.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 com.intellij.util.ArrayUtil; -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 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"); - - final PsiElement psiElement = firstChild.getFirstChild(); - if (!(psiElement instanceof PsiJavaCodeReferenceElement)) { - return JavaErrorMessages.message("javadoc.exception.tag.wrong.tag.value"); - } - - 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))) { - 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))) { - return null; - } - - PsiMethod method = PsiTreeUtil.getParentOfType(value, PsiMethod.class); - if (method == null) { - return null; - } - final PsiClassType[] references = method.getThrowsList().getReferencedTypes(); - - for (PsiClassType reference : references) { - final PsiClass psiClass = reference.resolve(); - if (psiClass == null) continue; - if (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 String getName() { - return myName; - } - - @Override - public Object[] getPossibleValues(PsiElement context, PsiElement place, String prefix) { - return ArrayUtil.EMPTY_OBJECT_ARRAY; - } - - @Override - public PsiReference getReference(PsiDocTagValue value) { - return null; - } - - @Override - public boolean isValidInContext(PsiElement element) { - if (!(element instanceof PsiMethod)) return false; - return true; - } - - @Override - public boolean isInline() { - return false; - } -} diff --git a/java/java-impl/src/com/intellij/psi/impl/source/javadoc/JavadocManagerImpl.java b/java/java-impl/src/com/intellij/psi/impl/source/javadoc/JavadocManagerImpl.java deleted file mode 100644 index 939d7f707c2e..000000000000 --- a/java/java-impl/src/com/intellij/psi/impl/source/javadoc/JavadocManagerImpl.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright 2000-2013 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.impl.source.javadoc; - -import com.intellij.codeInspection.SuppressionUtil; -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.JavadocManager; -import com.intellij.psi.javadoc.JavadocTagInfo; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -/** - * @author mike - */ -public class JavadocManagerImpl implements JavadocManager { - private final List<JavadocTagInfo> myInfos; - - public JavadocManagerImpl(Project project) { - myInfos = new ArrayList<JavadocTagInfo>(); - - myInfos.add(new SimpleDocTagInfo("author", PsiClass.class, PsiPackage.class, LanguageLevel.JDK_1_3)); - myInfos.add(new SimpleDocTagInfo("deprecated", PsiElement.class, false, LanguageLevel.JDK_1_3)); - myInfos.add(new SimpleDocTagInfo("serialData", PsiMethod.class, false, LanguageLevel.JDK_1_3)); - myInfos.add(new SimpleDocTagInfo("serialField", PsiField.class, false, LanguageLevel.JDK_1_3)); - myInfos.add(new SimpleDocTagInfo("since", PsiElement.class, PsiPackage.class, LanguageLevel.JDK_1_3)); - myInfos.add(new SimpleDocTagInfo("version", PsiClass.class, PsiPackage.class, LanguageLevel.JDK_1_3)); - - myInfos.add(new SimpleDocTagInfo("docRoot", PsiElement.class, true, LanguageLevel.JDK_1_3)); - myInfos.add(new SimpleDocTagInfo("inheritDoc", PsiElement.class, true, LanguageLevel.JDK_1_4)); - myInfos.add(new SimpleDocTagInfo("literal", PsiElement.class, true, LanguageLevel.JDK_1_5)); - myInfos.add(new SimpleDocTagInfo("code", PsiElement.class, true, LanguageLevel.JDK_1_5)); - - //Not a standard tag, but added by IDEA for inspection suppression - myInfos.add(new SimpleDocTagInfo(SuppressionUtil.SUPPRESS_INSPECTIONS_TAG_NAME, PsiElement.class, false, LanguageLevel.JDK_1_3)); - - myInfos.add(new ParamDocTagInfo()); - myInfos.add(new ReturnDocTagInfo()); - myInfos.add(new SerialDocTagInfo()); - myInfos.add(new SeeDocTagInfo("see", false)); - myInfos.add(new SeeDocTagInfo("link", true)); - myInfos.add(new SeeDocTagInfo("linkplain", true)); - myInfos.add(new ExceptionTagInfo("exception")); - myInfos.add(new ExceptionTagInfo("throws")); - myInfos.add(new ValueDocTagInfo()); - Collections.addAll(myInfos, Extensions.getExtensions(JavadocTagInfo.EP_NAME, project)); - } - - @Deprecated - public void registerTagInfo(@NotNull JavadocTagInfo info) { - myInfos.add(info); - } - - @Override - @NotNull - public JavadocTagInfo[] getTagInfos(PsiElement context) { - List<JavadocTagInfo> result = new ArrayList<JavadocTagInfo>(); - - for (JavadocTagInfo info : myInfos) { - if (info.isValidInContext(context)) { - result.add(info); - } - } - - return result.toArray(new JavadocTagInfo[result.size()]); - } - - @Override - @Nullable - public JavadocTagInfo getTagInfo(String name) { - for (JavadocTagInfo info : myInfos) { - if (info.getName().equals(name)) return info; - } - - return null; - } -} diff --git a/java/java-impl/src/com/intellij/psi/impl/source/javadoc/ParamDocTagInfo.java b/java/java-impl/src/com/intellij/psi/impl/source/javadoc/ParamDocTagInfo.java deleted file mode 100644 index 1dfbe582adf8..000000000000 --- a/java/java-impl/src/com/intellij/psi/impl/source/javadoc/ParamDocTagInfo.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright 2000-2012 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.impl.source.javadoc; - -import com.intellij.codeInsight.daemon.JavaErrorMessages; -import com.intellij.lang.ASTNode; -import com.intellij.psi.*; -import com.intellij.psi.javadoc.JavadocTagInfo; -import com.intellij.psi.javadoc.PsiDocTagValue; -import com.intellij.psi.util.PsiUtil; -import com.intellij.util.ArrayUtil; -import com.intellij.util.containers.ContainerUtil; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -/** - * @author mike - */ -class ParamDocTagInfo implements JavadocTagInfo { - @Override - public String getName() { - return "param"; - } - - @Override - public boolean isValidInContext(PsiElement element) { - return element instanceof PsiMethod || - (element instanceof PsiClass && PsiUtil.isLanguageLevel5OrHigher(element)); - } - - @Override - public Object[] getPossibleValues(PsiElement context, PsiElement place, String prefix) { - if (context instanceof PsiTypeParameterListOwner) { - List<PsiNamedElement> result = new ArrayList<PsiNamedElement>(Arrays.asList(((PsiTypeParameterListOwner)context).getTypeParameters())); - - if (context instanceof PsiMethod) { - PsiMethod method = (PsiMethod)context; - ContainerUtil.addAll(result, method.getParameterList().getParameters()); - } - - return result.toArray(new PsiNamedElement[result.size()]); - } - - return ArrayUtil.EMPTY_OBJECT_ARRAY; - } - - @Override - public String checkTagValue(PsiDocTagValue value) { - if (value == null) return JavaErrorMessages.message("javadoc.param.tag.parameter.name.expected"); - final ASTNode firstChildNode = value.getNode().getFirstChildNode(); - if (firstChildNode != null && - firstChildNode.getElementType().equals(JavaDocTokenType.DOC_TAG_VALUE_LT)) { - if (value.getNode().findChildByType(JavaDocTokenType.DOC_TAG_VALUE_TOKEN) == null) { - return JavaErrorMessages.message("javadoc.param.tag.type.parameter.name.expected"); - } - - if (value.getNode().findChildByType(JavaDocTokenType.DOC_TAG_VALUE_GT) == null) { - return JavaErrorMessages.message("javadoc.param.tag.type.parameter.gt.expected"); - } - } - return null; - } - - @Override - public PsiReference getReference(PsiDocTagValue value) { - if (value instanceof PsiDocParamRef) return value.getReference(); - return null; - } - - - @Override - public boolean isInline() { - return false; - } -} diff --git a/java/java-impl/src/com/intellij/psi/impl/source/javadoc/PsiDocTagValueImpl.java b/java/java-impl/src/com/intellij/psi/impl/source/javadoc/PsiDocTagValueImpl.java deleted file mode 100644 index 89e4a844a409..000000000000 --- a/java/java-impl/src/com/intellij/psi/impl/source/javadoc/PsiDocTagValueImpl.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2000-2009 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.impl.source.javadoc; - -import com.intellij.psi.PsiReference; -import com.intellij.psi.javadoc.JavadocManager; -import com.intellij.psi.javadoc.JavadocTagInfo; -import com.intellij.psi.javadoc.PsiDocTag; -import com.intellij.psi.util.PsiTreeUtil; - -/** - * @author mike - */ -public class PsiDocTagValueImpl extends CorePsiDocTagValueImpl { - @Override - public PsiReference getReference() { - PsiDocTag docTag = PsiTreeUtil.getParentOfType(this, PsiDocTag.class); - if (docTag == null) { - return null; - } - final String name = docTag.getName(); - final JavadocManager manager = JavadocManager.SERVICE.getInstance(getProject()); - final JavadocTagInfo info = manager.getTagInfo(name); - if (info == null) return null; - - return info.getReference(this); - } -} diff --git a/java/java-impl/src/com/intellij/psi/impl/source/javadoc/ReturnDocTagInfo.java b/java/java-impl/src/com/intellij/psi/impl/source/javadoc/ReturnDocTagInfo.java deleted file mode 100644 index edffa28d3e3d..000000000000 --- a/java/java-impl/src/com/intellij/psi/impl/source/javadoc/ReturnDocTagInfo.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright 2000-2009 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.impl.source.javadoc; - -import com.intellij.psi.javadoc.JavadocTagInfo; -import com.intellij.psi.javadoc.PsiDocTagValue; -import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiReference; -import com.intellij.psi.PsiMethod; -import com.intellij.psi.PsiType; -import com.intellij.util.ArrayUtil; - -/** - * @author mike - */ -class ReturnDocTagInfo implements JavadocTagInfo { - @Override - public String checkTagValue(PsiDocTagValue value) { - return null; - } - - @Override - public String getName() { - return "return"; - } - - @Override - public Object[] getPossibleValues(PsiElement context, PsiElement place, String prefix) { - return ArrayUtil.EMPTY_OBJECT_ARRAY; - } - - @Override - public PsiReference getReference(PsiDocTagValue value) { - return null; - } - - @Override - public boolean isValidInContext(PsiElement element) { - if (!(element instanceof PsiMethod)) return false; - PsiMethod method = (PsiMethod)element; - final PsiType type = method.getReturnType(); - if (type == null) return false; - return type != PsiType.VOID; - } - - @Override - public boolean isInline() { - return false; - } -} diff --git a/java/java-impl/src/com/intellij/psi/impl/source/javadoc/SeeDocTagInfo.java b/java/java-impl/src/com/intellij/psi/impl/source/javadoc/SeeDocTagInfo.java deleted file mode 100644 index e7eb4dfb4836..000000000000 --- a/java/java-impl/src/com/intellij/psi/impl/source/javadoc/SeeDocTagInfo.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright 2000-2009 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.impl.source.javadoc; - -import com.intellij.pom.java.LanguageLevel; -import com.intellij.psi.*; -import com.intellij.psi.util.PsiUtil; -import com.intellij.psi.impl.source.SourceTreeToPsiMap; -import com.intellij.psi.impl.source.tree.ElementType; -import com.intellij.psi.javadoc.JavadocTagInfo; -import com.intellij.psi.javadoc.PsiDocTagValue; -import com.intellij.psi.javadoc.PsiDocToken; -import com.intellij.psi.tree.IElementType; -import com.intellij.util.ArrayUtil; -import org.jetbrains.annotations.NonNls; - -import java.util.ArrayList; -import java.util.List; - -/** - * @author mike - */ -class SeeDocTagInfo implements JavadocTagInfo { - private final String myName; - private final boolean myInline; - private static final @NonNls String LINKPLAIN_TAG = "linkplain"; - - public SeeDocTagInfo(@NonNls String name, boolean isInline) { - myName = name; - myInline = isInline; - } - - @Override - public String checkTagValue(PsiDocTagValue value) { - return null; - } - - @Override - public String getName() { - return myName; - } - - @Override - public Object[] getPossibleValues(PsiElement context, PsiElement place, String prefix) { - if (place instanceof PsiDocToken) { - PsiDocToken token = (PsiDocToken) place; - if (token.getTokenType() == JavaDocTokenType.DOC_TAG_VALUE_SHARP_TOKEN) { - return getPossibleMethodsAndFields(context, place, prefix); - } else if (token.getTokenType() == JavaDocTokenType.DOC_TAG_VALUE_LPAREN) { - if (token.getPrevSibling() == null) return ArrayUtil.EMPTY_OBJECT_ARRAY; - final String methodName = token.getPrevSibling().getText(); - - PsiElement targetContext = getTargetContext(context, place); - - List<PsiMethod> result = new ArrayList<PsiMethod>(); - final PsiMethod[] methods = PsiDocMethodOrFieldRef.getAllMethods(targetContext, place); - for (final PsiMethod method : methods) { - if (method.getName().equals(methodName)) { - result.add(method); - } - } - return ArrayUtil.toObjectArray(result); - } else if (token.getTokenType() == JavaDocTokenType.DOC_TAG_VALUE_TOKEN && place.getParent() instanceof PsiDocMethodOrFieldRef) { - return getPossibleMethodsAndFields(context, place, prefix); - } - } - - return ArrayUtil.EMPTY_OBJECT_ARRAY; - } - - private Object[] getPossibleMethodsAndFields(PsiElement context, PsiElement place, String prefix) { - List<PsiModifierListOwner> result = new ArrayList<PsiModifierListOwner>(); - - PsiElement targetContext = getTargetContext(context, place); - - final PsiMethod[] methods = PsiDocMethodOrFieldRef.getAllMethods(targetContext, place); - for (PsiMethod method : methods) { - result.add(method); - } - - final PsiVariable[] variables = PsiDocMethodOrFieldRef.getAllVariables(targetContext, place); - for (PsiVariable variable : variables) { - result.add(variable); - } - - return ArrayUtil.toObjectArray(result); - } - - private PsiElement getTargetContext(PsiElement context, PsiElement place) { - PsiElement targetContext = context; - - if (place.getParent() instanceof PsiDocMethodOrFieldRef) { - PsiDocMethodOrFieldRef methodRef = (PsiDocMethodOrFieldRef) place.getParent(); - - final IElementType firstChildType = methodRef.getFirstChildNode().getElementType(); - if (firstChildType == ElementType.JAVA_CODE_REFERENCE || firstChildType == ElementType.REFERENCE_EXPRESSION) { - PsiJavaCodeReferenceElement referenceElement = (PsiJavaCodeReferenceElement) SourceTreeToPsiMap.treeElementToPsi(methodRef.getFirstChildNode()); - final PsiElement element = referenceElement.resolve(); - if (element instanceof PsiClass) { - targetContext = element.getFirstChild(); - } - } - } - return targetContext; - } - - @Override - public boolean isValidInContext(PsiElement element) { - if (myInline && myName.equals(LINKPLAIN_TAG)) - return PsiUtil.getLanguageLevel(element).compareTo(LanguageLevel.JDK_1_4) >= 0; - - return true; - } - - @Override - public PsiReference getReference(PsiDocTagValue value) { - return null; - } - - @Override - public boolean isInline() { - return myInline; - } -} diff --git a/java/java-impl/src/com/intellij/psi/impl/source/javadoc/SerialDocTagInfo.java b/java/java-impl/src/com/intellij/psi/impl/source/javadoc/SerialDocTagInfo.java deleted file mode 100644 index 2b7fa7981f46..000000000000 --- a/java/java-impl/src/com/intellij/psi/impl/source/javadoc/SerialDocTagInfo.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2000-2009 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.impl.source.javadoc; - -import com.intellij.psi.PsiClass; -import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiField; -import com.intellij.psi.PsiReference; -import com.intellij.psi.javadoc.JavadocTagInfo; -import com.intellij.psi.javadoc.PsiDocTagValue; -import com.intellij.util.ArrayUtil; - -public class SerialDocTagInfo implements JavadocTagInfo { - @Override - public String getName() { - return "serial"; - } - - @Override - public boolean isInline() { - return false; - } - - @Override - public boolean isValidInContext(PsiElement element) { - return element instanceof PsiClass || element instanceof PsiField; - } - - @Override - public Object[] getPossibleValues(PsiElement context, PsiElement place, String prefix) { - return ArrayUtil.EMPTY_OBJECT_ARRAY; - } - - @Override - public String checkTagValue(PsiDocTagValue value) { - return null; - } - - @Override - public PsiReference getReference(PsiDocTagValue value) { - return null; - } -} diff --git a/java/java-impl/src/com/intellij/psi/impl/source/javadoc/SimpleDocTagInfo.java b/java/java-impl/src/com/intellij/psi/impl/source/javadoc/SimpleDocTagInfo.java deleted file mode 100644 index d16f4d8be4a7..000000000000 --- a/java/java-impl/src/com/intellij/psi/impl/source/javadoc/SimpleDocTagInfo.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright 2000-2013 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.impl.source.javadoc; - -import com.intellij.pom.java.LanguageLevel; -import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiReference; -import com.intellij.psi.util.PsiUtil; -import com.intellij.psi.javadoc.JavadocTagInfo; -import com.intellij.psi.javadoc.PsiDocTagValue; -import com.intellij.util.ArrayUtil; -import org.jetbrains.annotations.NonNls; - -/** - * @author mike - */ -class SimpleDocTagInfo implements JavadocTagInfo { - private final String myName; - private final Class myContext; - private final Class myAdditionalContext; - private final boolean myInline; - private final LanguageLevel myLanguageLevel; - - public SimpleDocTagInfo(@NonNls String name, Class context, boolean isInline, LanguageLevel level) { - myName = name; - myContext = context; - myAdditionalContext = null; - myInline = isInline; - myLanguageLevel = level; - } - - public SimpleDocTagInfo(@NonNls String name, Class context, Class additionalContext, LanguageLevel level) { - myName = name; - myContext = context; - myAdditionalContext = additionalContext; - myInline = false; - myLanguageLevel = level; - } - - @Override - public String getName() { - return myName; - } - - @Override - public boolean isValidInContext(PsiElement element) { - if (PsiUtil.getLanguageLevel(element).compareTo(myLanguageLevel) < 0) { - return false; - } - - return myContext.isInstance(element) || (myAdditionalContext != null && myAdditionalContext.isInstance(element)); - } - - @Override - public Object[] getPossibleValues(PsiElement context, PsiElement place, String prefix) { - return ArrayUtil.EMPTY_OBJECT_ARRAY; - } - - @Override - public String checkTagValue(PsiDocTagValue value) { - return null; - } - - @Override - public PsiReference getReference(PsiDocTagValue value) { - return null; - } - - @Override - public boolean isInline() { - return myInline; - } -} diff --git a/java/java-impl/src/com/intellij/psi/impl/source/javadoc/ValueDocTagInfo.java b/java/java-impl/src/com/intellij/psi/impl/source/javadoc/ValueDocTagInfo.java deleted file mode 100644 index 76b350b1a2db..000000000000 --- a/java/java-impl/src/com/intellij/psi/impl/source/javadoc/ValueDocTagInfo.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright 2000-2012 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.impl.source.javadoc; - -import com.intellij.codeInsight.daemon.JavaErrorMessages; -import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiField; -import com.intellij.psi.PsiModifier; -import com.intellij.psi.PsiReference; -import com.intellij.psi.impl.JavaConstantExpressionEvaluator; -import com.intellij.psi.javadoc.JavadocTagInfo; -import com.intellij.psi.javadoc.PsiDocTagValue; -import com.intellij.psi.util.PsiUtil; - -/** - * @author yole - */ -public class ValueDocTagInfo implements JavadocTagInfo { - @Override - public String getName() { - return "value"; - } - - @Override - public boolean isInline() { - return true; - } - - @Override - public boolean isValidInContext(PsiElement element) { - return true; - } - - @Override - public Object[] getPossibleValues(PsiElement context, PsiElement place, String prefix) { - return null; - } - - @Override - public String checkTagValue(PsiDocTagValue value) { - boolean hasReference = (value != null && value.getFirstChild() != null); - if (hasReference) { - if (!PsiUtil.isLanguageLevel5OrHigher(value)) { - return JavaErrorMessages.message("javadoc.value.tag.jdk15.required"); - } - } - - if (value != null) { - PsiReference reference = value.getReference(); - if (reference != null) { - PsiElement target = reference.resolve(); - if (target != null) { - if (!(target instanceof PsiField)) { - return JavaErrorMessages.message("javadoc.value.field.required"); - } - PsiField field = (PsiField) target; - if (!field.hasModifierProperty(PsiModifier.STATIC)) { - return JavaErrorMessages.message("javadoc.value.static.field.required"); - } - if (field.getInitializer() == null || - JavaConstantExpressionEvaluator.computeConstantExpression(field.getInitializer(), false) == null) { - return JavaErrorMessages.message("javadoc.value.field.with.initializer.required"); - } - } - } - } - - return null; - } - - @Override - public PsiReference getReference(PsiDocTagValue value) { - return null; - } -} |