Cleanup (unused code)

This commit is contained in:
Roman Shevchenko
2016-03-09 12:42:42 +01:00
parent 55af2c9fdd
commit 4176064485
10 changed files with 79 additions and 229 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* 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.
@@ -18,7 +18,6 @@ package com.intellij.psi.javadoc;
import com.intellij.openapi.extensions.ExtensionPointName;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiReference;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.Nullable;
/**
@@ -27,13 +26,12 @@ import org.jetbrains.annotations.Nullable;
public interface JavadocTagInfo {
ExtensionPointName<JavadocTagInfo> EP_NAME = ExtensionPointName.create("com.intellij.javadocTagInfo");
@NonNls String getName();
String getName();
boolean isInline();
boolean isValidInContext(PsiElement element);
Object[] getPossibleValues(PsiElement context, PsiElement place, String prefix);
/**
* Checks the tag value for correctness.
*
@@ -45,4 +43,4 @@ public interface JavadocTagInfo {
@Nullable
PsiReference getReference(PsiDocTagValue value);
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* 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.
@@ -20,7 +20,6 @@ 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;
/**
@@ -33,6 +32,22 @@ class ExceptionTagInfo implements JavadocTagInfo {
myName = name;
}
@Override
public String getName() {
return myName;
}
@Override
public boolean isInline() {
return false;
}
@Override
public boolean isValidInContext(PsiElement element) {
if (!(element instanceof PsiMethod)) return false;
return true;
}
@Override
public String checkTagValue(PsiDocTagValue value) {
if (value == null) return JavaErrorMessages.message("javadoc.exception.tag.exception.class.expected");
@@ -89,29 +104,8 @@ class ExceptionTagInfo implements JavadocTagInfo {
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;
}
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* 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.
@@ -68,16 +68,12 @@ public class JavadocManagerImpl implements JavadocManager {
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
public void registerTagInfo(@NotNull JavadocTagInfo info) {
myInfos.add(info);
}
@Override
@NotNull
public JavadocTagInfo[] getTagInfos(PsiElement context) {
@@ -96,9 +92,11 @@ public class JavadocManagerImpl implements JavadocManager {
@Nullable
public JavadocTagInfo getTagInfo(String name) {
for (JavadocTagInfo info : myInfos) {
if (info.getName().equals(name)) return info;
if (info.getName().equals(name)) {
return info;
}
}
return null;
}
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* 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.
@@ -21,12 +21,6 @@ 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
@@ -38,25 +32,14 @@ class ParamDocTagInfo implements JavadocTagInfo {
}
@Override
public boolean isValidInContext(PsiElement element) {
return element instanceof PsiMethod ||
(element instanceof PsiClass && PsiUtil.isLanguageLevel5OrHigher(element));
public boolean isInline() {
return false;
}
@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;
public boolean isValidInContext(PsiElement element) {
return element instanceof PsiMethod ||
(element instanceof PsiClass && PsiUtil.isLanguageLevel5OrHigher(element));
}
@Override
@@ -81,10 +64,4 @@ class ParamDocTagInfo implements JavadocTagInfo {
if (value instanceof PsiDocParamRef) return value.getReference();
return null;
}
@Override
public boolean isInline() {
return false;
}
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* 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.
@@ -21,30 +21,19 @@ import com.intellij.psi.PsiReference;
import com.intellij.psi.PsiType;
import com.intellij.psi.javadoc.JavadocTagInfo;
import com.intellij.psi.javadoc.PsiDocTagValue;
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;
public boolean isInline() {
return false;
}
@Override
@@ -57,7 +46,12 @@ class ReturnDocTagInfo implements JavadocTagInfo {
}
@Override
public boolean isInline() {
return false;
public String checkTagValue(PsiDocTagValue value) {
return null;
}
}
@Override
public PsiReference getReference(PsiDocTagValue value) {
return null;
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* 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.
@@ -16,123 +16,53 @@
package com.intellij.psi.impl.source.javadoc;
import com.intellij.pom.java.LanguageLevel;
import com.intellij.psi.*;
import com.intellij.psi.impl.source.tree.JavaElementType;
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.PsiElement;
import com.intellij.psi.PsiReference;
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;
import com.intellij.psi.util.PsiUtil;
/**
* @author mike
*/
class SeeDocTagInfo implements JavadocTagInfo {
private static final String LINKPLAIN_TAG = "linkplain";
private final String myName;
private final boolean myInline;
@NonNls private static final String LINKPLAIN_TAG = "linkplain";
public SeeDocTagInfo(@NonNls String name, boolean isInline) {
public SeeDocTagInfo(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;
public boolean isInline() {
return myInline;
}
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 == JavaElementType.JAVA_CODE_REFERENCE || firstChildType == JavaElementType.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) && element != null)
if (myInline && myName.equals(LINKPLAIN_TAG) && element != null) {
return PsiUtil.getLanguageLevel(element).compareTo(LanguageLevel.JDK_1_4) >= 0;
}
return true;
}
@Override
public String checkTagValue(PsiDocTagValue value) {
return null;
}
@Override
public PsiReference getReference(PsiDocTagValue value) {
return null;
}
@Override
public boolean isInline() {
return myInline;
}
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* 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.
@@ -21,7 +21,6 @@ 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
@@ -39,11 +38,6 @@ public class SerialDocTagInfo implements JavadocTagInfo {
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;
@@ -53,4 +47,4 @@ public class SerialDocTagInfo implements JavadocTagInfo {
public PsiReference getReference(PsiDocTagValue value) {
return null;
}
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* 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.
@@ -18,10 +18,9 @@ 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 com.intellij.psi.util.PsiUtil;
import org.jetbrains.annotations.NonNls;
/**
@@ -55,6 +54,11 @@ class SimpleDocTagInfo implements JavadocTagInfo {
return myName;
}
@Override
public boolean isInline() {
return myInline;
}
@Override
public boolean isValidInContext(PsiElement element) {
if (element != null && PsiUtil.getLanguageLevel(element).compareTo(myLanguageLevel) < 0) {
@@ -64,11 +68,6 @@ class SimpleDocTagInfo implements JavadocTagInfo {
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;
@@ -78,9 +77,4 @@ class SimpleDocTagInfo implements JavadocTagInfo {
public PsiReference getReference(PsiDocTagValue value) {
return null;
}
@Override
public boolean isInline() {
return myInline;
}
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* 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.
@@ -44,11 +44,6 @@ public class ValueDocTagInfo implements JavadocTagInfo {
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);
@@ -85,4 +80,4 @@ public class ValueDocTagInfo implements JavadocTagInfo {
public PsiReference getReference(PsiDocTagValue value) {
return null;
}
}
}
@@ -1,20 +1,5 @@
/*
* 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.
* 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.
@@ -28,6 +13,7 @@ package org.jetbrains.idea.maven.javadoc;/*
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.idea.maven.javadoc;
import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiElement;
@@ -44,7 +30,6 @@ import org.jetbrains.annotations.Nullable;
import java.util.List;
public class MojoClassAnnotationTagProvider implements CustomJavadocTagProvider {
private static final String[] ANNOTATION_NAMES = {
"goal",
"requiresDependencyResolution",
@@ -66,12 +51,11 @@ public class MojoClassAnnotationTagProvider implements CustomJavadocTagProvider
}
});
}
}
class MojoAnnotationInfo implements JavadocTagInfo {
private static final String BASE_CLASS = "org.apache.maven.plugin.Mojo";
private final String myName;
public MojoAnnotationInfo(@NotNull String name) {
@@ -97,11 +81,6 @@ class MojoAnnotationInfo implements JavadocTagInfo {
return false;
}
@Override
public Object[] getPossibleValues(PsiElement context, PsiElement place, String prefix) {
return null;
}
@Nullable
@Override
public String checkTagValue(PsiDocTagValue value) {
@@ -113,7 +92,4 @@ class MojoAnnotationInfo implements JavadocTagInfo {
public PsiReference getReference(PsiDocTagValue value) {
return null;
}
}
}