Unneeded methods deprecated

This commit is contained in:
Roman Shevchenko
2013-04-04 19:38:46 +02:00
parent fc602c65bc
commit c730019888
19 changed files with 36 additions and 191 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2011 JetBrains s.r.o.
* 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.
@@ -110,7 +110,7 @@ public class LightField extends LightElement implements PsiField {
@Override
public PsiType getTypeNoResolve() {
return myField.getTypeNoResolve();
return getType();
}
@Override
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* 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.
@@ -200,6 +200,6 @@ public interface PsiMethod extends PsiMember, PsiNameIdentifierOwner, PsiModifie
@NotNull
HierarchicalMethodSignature getHierarchicalMethodSignature();
@Nullable
/** @deprecated use {@link #getReturnType()} (to remove in IDEA 13) */
PsiType getReturnTypeNoResolve();
}
@@ -53,8 +53,9 @@ public interface PsiTypeElement extends PsiElement,PsiAnnotationOwner {
@Nullable
PsiJavaCodeReferenceElement getInnermostComponentReferenceElement();
/** @deprecated equals to getType() (to remove in IDEA 13) */
/** @deprecated use {@link PsiAnnotation#getOwner()} (to remove in IDEA 13) */
PsiAnnotationOwner getOwner(PsiAnnotation annotation);
/** @deprecated use {@link #getType()} (to remove in IDEA 13) */
PsiType getTypeNoResolve(@NotNull PsiElement context);
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* 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.
@@ -90,5 +90,6 @@ public interface PsiVariable extends PsiModifierListOwner, PsiNameIdentifierOwne
@Override
PsiElement setName(@NonNls @NotNull String name) throws IncorrectOperationException;
/** @deprecated use {@link #getType()} (to remove in IDEA 13) */
PsiType getTypeNoResolve();
}
@@ -124,28 +124,12 @@ public class PsiFieldImpl extends JavaStubPsiElement<PsiFieldStub> implements Ps
@Override
public PsiType getTypeNoResolve() {
final PsiFieldStub stub = getStub();
if (stub != null) {
String typeText = TypeInfo.createTypeText(stub.getType(false));
try {
final PsiType type = JavaPsiFacade.getInstance(getProject()).getParserFacade().createTypeFromText(typeText, this);
myCachedType = new SoftReference<PsiType>(type);
return type;
}
catch (IncorrectOperationException e) {
LOG.error(e);
return null;
}
}
PsiTypeElement typeElement = getTypeElement();
PsiIdentifier nameIdentifier = getNameIdentifier();
return JavaSharedImplUtil.getTypeNoResolve(typeElement, nameIdentifier, this);
return getType();
}
@Override
@NotNull
public PsiType getType(){
public PsiType getType() {
final PsiFieldStub stub = getStub();
if (stub != null) {
SoftReference<PsiType> cachedType = myCachedType;
@@ -167,7 +151,7 @@ public class PsiFieldImpl extends JavaStubPsiElement<PsiFieldStub> implements Ps
}
myCachedType = null;
return JavaSharedImplUtil.getType(getTypeElement(), getNameIdentifier(), this);
return JavaSharedImplUtil.getType(getTypeElement(), getNameIdentifier());
}
@Override
@@ -189,26 +189,7 @@ public class PsiMethodImpl extends JavaStubPsiElement<PsiMethodStub> implements
@Override
public PsiType getReturnTypeNoResolve() {
if (isConstructor()) return null;
final PsiMethodStub stub = getStub();
if (stub != null) {
final String typeText = TypeInfo.createTypeText(stub.getReturnTypeText(false));
if (typeText == null) return null;
try {
return JavaPsiFacade.getInstance(getProject()).getElementFactory().createTypeFromText(typeText, this);
}
catch(IncorrectOperationException e){
LOG.error(e);
return null;
}
}
PsiTypeElement typeElement = getReturnTypeElement();
if (typeElement == null) return null;
PsiParameterList parameterList = getParameterList();
return JavaSharedImplUtil.getTypeNoResolve(typeElement, parameterList, this);
return getReturnType();
}
@Override
@@ -241,7 +222,7 @@ public class PsiMethodImpl extends JavaStubPsiElement<PsiMethodStub> implements
PsiTypeElement typeElement = getReturnTypeElement();
if (typeElement == null) return null;
PsiParameterList parameterList = getParameterList();
return JavaSharedImplUtil.getType(typeElement, parameterList, this);
return JavaSharedImplUtil.getType(typeElement, parameterList);
}
@Override
@@ -143,33 +143,13 @@ public class PsiParameterImpl extends JavaStubPsiElement<PsiParameterStub> imple
return LambdaUtil.getLambdaParameterType(this);
}
else {
return JavaSharedImplUtil.getType(typeElement, getParameterIdentifier(), this);
return JavaSharedImplUtil.getType(typeElement, getParameterIdentifier());
}
}
@Override
public PsiType getTypeNoResolve() {
PsiParameterStub stub = getStub();
if (stub != null) {
String typeText = TypeInfo.createTypeText(stub.getType(false));
assert typeText != null : stub;
try {
return JavaPsiFacade.getInstance(getProject()).getParserFacade().createTypeFromText(typeText, this);
}
catch (IncorrectOperationException e) {
LOG.error(e);
return null;
}
}
final PsiTypeElement typeElement = getTypeElement();
if (typeElement == null) {
assert isLambdaParameter() : this;
return new PsiLambdaParameterType(this);
}
else {
return JavaSharedImplUtil.getTypeNoResolve(typeElement, getParameterIdentifier(), this);
}
return getType();
}
private boolean isLambdaParameter() {
@@ -17,9 +17,7 @@ package com.intellij.psi.impl.source;
import com.intellij.lang.ASTNode;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.*;
import com.intellij.psi.impl.DebugUtil;
import com.intellij.psi.impl.PsiImplUtil;
import com.intellij.psi.impl.source.codeStyle.CodeEditUtil;
import com.intellij.psi.impl.source.tree.*;
@@ -191,33 +189,9 @@ public class PsiTypeElementImpl extends CompositePsiElement implements PsiTypeEl
});
}
private static final Function<PsiAnnotation, String> ANNOTATION_TEXT = new Function<PsiAnnotation, String>() {
@Override
public String fun(PsiAnnotation psiAnnotation) {
return psiAnnotation.getText();
}
};
@Override
public PsiType getTypeNoResolve(@NotNull PsiElement context) {
PsiFile file = getContainingFile();
String text;
if (PsiUtil.isLanguageLevel8OrHigher(file)) {
String combinedAnnotations = StringUtil.join(getAnnotations(), ANNOTATION_TEXT, " ");
text = combinedAnnotations.isEmpty() ? getText().trim() : combinedAnnotations + " " + getText().trim();
}
else {
text = getText().trim();
}
try {
return JavaPsiFacade.getInstance(getProject()).getElementFactory().createTypeFromText(text, context);
}
catch (IncorrectOperationException e) {
String s = "Parent: " + DebugUtil.psiToString(getParent(), false);
s += "Context: " + DebugUtil.psiToString(context, false);
LOG.error(s, e);
return null;
}
return getType();
}
@Override
@@ -38,7 +38,7 @@ public class JavaSharedImplUtil {
private JavaSharedImplUtil() { }
public static PsiType getType(@NotNull PsiTypeElement typeElement, @NotNull PsiElement anchor, @NotNull PsiElement context) {
public static PsiType getType(@NotNull PsiTypeElement typeElement, @NotNull PsiElement anchor) {
PsiType type = typeElement.getType();
List<PsiAnnotation[]> allAnnotations = collectAnnotations(anchor);
@@ -49,17 +49,6 @@ public class JavaSharedImplUtil {
return type;
}
public static PsiType getTypeNoResolve(@NotNull PsiTypeElement typeElement, @NotNull PsiElement anchor, @NotNull PsiElement context) {
PsiType type = typeElement.getTypeNoResolve(context);
List<PsiAnnotation[]> allAnnotations = collectAnnotations(anchor);
for (PsiAnnotation[] annotations : allAnnotations) {
type = type.createArrayType(annotations);
}
return type;
}
private static List<PsiAnnotation[]> collectAnnotations(PsiElement anchor) {
List<PsiAnnotation[]> annotations = new SmartList<PsiAnnotation[]>();
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* 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.
@@ -95,7 +95,7 @@ public class PsiLocalVariableImpl extends CompositePsiElement implements PsiLoca
@Override
@NotNull
public final PsiType getType() {
return JavaSharedImplUtil.getType(getTypeElement(), getNameIdentifier(), this);
return JavaSharedImplUtil.getType(getTypeElement(), getNameIdentifier());
}
@Override
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* 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.
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.plugins.groovy.lang.psi.api.types;
import com.intellij.psi.PsiElement;
@@ -22,12 +21,13 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement;
/**
* @author: Dmitry.Krasilschikov
* @date: 28.03.2007
* @author Dmitry.Krasilschikov
* @date 28.03.2007
*/
public interface GrTypeElement extends GroovyPsiElement {
@NotNull
PsiType getType();
/** @deprecated use {@link #getType()} (to remove in IDEA 13) */
PsiType getTypeNoResolve(PsiElement context);
}
@@ -540,25 +540,7 @@ public abstract class GrMethodBaseImpl extends GrStubElementBase<GrMethodStub> i
}
public PsiType getReturnTypeNoResolve() {
if (isConstructor()) return null;
final GrMethodStub stub = getStub();
if (stub != null) {
final String typeText = stub.getTypeText();
if (typeText == null) return null;
try {
return JavaPsiFacade.getInstance(getProject()).getElementFactory().createTypeFromText(typeText, this);
}
catch(IncorrectOperationException e){
LOG.error(e);
return null;
}
}
GrTypeElement typeElement = getReturnTypeElementGroovy();
if (typeElement == null) return null;
return typeElement.getTypeNoResolve(this);
return getReturnType();
}
@Override
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* 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.
@@ -54,6 +54,6 @@ public class GrArrayTypeElementImpl extends GroovyPsiElementImpl implements GrAr
@Override
public PsiType getTypeNoResolve(PsiElement context) {
return GrTypeElementImplUtil.getTypeNoResolve(this, context);
return getType();
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* 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.
@@ -49,6 +49,6 @@ public class GrBuiltInTypeElementImpl extends GroovyPsiElementImpl implements Gr
@Override
public PsiType getTypeNoResolve(PsiElement context) {
return GrTypeElementImplUtil.getTypeNoResolve(this, context);
return getType();
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* 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.
@@ -55,6 +55,6 @@ public class GrClassTypeElementImpl extends GroovyPsiElementImpl implements GrCl
@Override
public PsiType getTypeNoResolve(PsiElement context) {
return GrTypeElementImplUtil.getTypeNoResolve(this, context);
return getType();
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2011 JetBrains s.r.o.
* 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.
@@ -70,7 +70,7 @@ public class GrDisjunctionTypeElementImpl extends GroovyPsiElementImpl implement
@Override
public PsiType getTypeNoResolve(PsiElement context) {
return GrTypeElementImplUtil.getTypeNoResolve(this, context);
return getType();
}
@Override
@@ -1,47 +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 org.jetbrains.plugins.groovy.lang.psi.impl.types;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.psi.JavaPsiFacade;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiType;
import com.intellij.psi.impl.DebugUtil;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.plugins.groovy.lang.psi.api.types.GrTypeElement;
/**
* @author Max Medvedev
*/
public class GrTypeElementImplUtil {
private static final Logger LOG = Logger.getInstance(GrTypeElementImplUtil.class);
private GrTypeElementImplUtil(){}
public static PsiType getTypeNoResolve(GrTypeElement typeElement, PsiElement context) {
String text = typeElement.getText().trim();
try {
return JavaPsiFacade.getInstance(typeElement.getProject()).getElementFactory().createTypeFromText(text, context);
}
catch (IncorrectOperationException e) {
String s = "Parent: " + DebugUtil.psiToString(typeElement.getParent(), false);
s += "Context: " + DebugUtil.psiToString(context, false);
LOG.error(s, e);
return null;
}
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* 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.
@@ -60,7 +60,7 @@ public class GrWildcardTypeArgumentImpl extends GroovyPsiElementImpl implements
@Override
public PsiType getTypeNoResolve(PsiElement context) {
return GrTypeElementImplUtil.getTypeNoResolve(this, context);
return getType();
}
public GrTypeElement getBoundTypeElement() {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* 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.
@@ -223,7 +223,7 @@ public class GrDynamicMethodImpl extends LightElement implements GrMethod {
}
public PsiType getReturnTypeNoResolve() {
return myMethod.getReturnTypeNoResolve();
return myMethod.getReturnType();
}
@Override