mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-13 21:55:01 +07:00
Drop support for outdated method receiver syntax
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -92,11 +92,9 @@ public class PreferByKindWeigher extends LookupElementWeigher {
|
||||
final PsiAnnotation annotation = PsiTreeUtil.getParentOfType(position, PsiAnnotation.class);
|
||||
assert annotation != null;
|
||||
PsiAnnotationOwner owner = annotation.getOwner();
|
||||
if (owner instanceof PsiModifierList || owner instanceof PsiTypeElement ||
|
||||
owner instanceof PsiMethodReceiver || owner instanceof PsiTypeParameter) {
|
||||
PsiElement member = ((PsiElement)owner).getParent();
|
||||
final String[] elementTypeFields = PsiAnnotationImpl
|
||||
.getApplicableElementTypeFields(owner instanceof PsiModifierList ? member : (PsiElement)owner);
|
||||
if (owner instanceof PsiModifierList || owner instanceof PsiTypeElement || owner instanceof PsiTypeParameter) {
|
||||
PsiElement member = owner instanceof PsiModifierList ? ((PsiElement)owner).getParent() : (PsiElement)owner;
|
||||
final String[] elementTypeFields = PsiAnnotationImpl.getApplicableElementTypeFields(member);
|
||||
return new Condition<PsiClass>() {
|
||||
@Override
|
||||
public boolean value(PsiClass psiClass) {
|
||||
|
||||
+1
-1
@@ -254,7 +254,7 @@ public class AnnotationsHighlightUtil {
|
||||
@Nullable
|
||||
public static HighlightInfo checkApplicability(final PsiAnnotation annotation) {
|
||||
PsiAnnotationOwner owner = annotation.getOwner();
|
||||
if (owner instanceof PsiModifierList || owner instanceof PsiTypeElement || owner instanceof PsiMethodReceiver || owner instanceof PsiTypeParameter) {
|
||||
if (owner instanceof PsiModifierList || owner instanceof PsiTypeElement || owner instanceof PsiTypeParameter) {
|
||||
PsiJavaCodeReferenceElement nameRef = annotation.getNameReferenceElement();
|
||||
if (nameRef == null) {
|
||||
return null;
|
||||
|
||||
@@ -395,11 +395,6 @@ public class LightMethodBuilder extends LightElement implements PsiMethod, Origi
|
||||
return getContainingFile();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiMethodReceiver getMethodReceiver() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public PsiType getReturnTypeNoResolve() {
|
||||
|
||||
@@ -207,9 +207,6 @@ public interface PsiMethod extends PsiMember, PsiNameIdentifierOwner, PsiModifie
|
||||
@NotNull
|
||||
HierarchicalMethodSignature getHierarchicalMethodSignature();
|
||||
|
||||
@Nullable
|
||||
PsiMethodReceiver getMethodReceiver();
|
||||
|
||||
@Nullable
|
||||
PsiType getReturnTypeNoResolve();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -15,8 +15,7 @@
|
||||
*/
|
||||
package com.intellij.psi;
|
||||
|
||||
/**
|
||||
* @author cdr
|
||||
*/
|
||||
/** @deprecated obsolete (to remove in IDEA 13) */
|
||||
@SuppressWarnings("UnusedDeclaration")
|
||||
public interface PsiMethodReceiver extends PsiAnnotationOwner, PsiParameter {
|
||||
}
|
||||
|
||||
@@ -333,7 +333,7 @@ public class DeclarationParser {
|
||||
}
|
||||
|
||||
if (!expect(builder, JavaTokenType.IDENTIFIER)) {
|
||||
if ((context == Context.CODE_BLOCK) && modListInfo.second) {
|
||||
if ((context == Context.CODE_BLOCK) && Boolean.TRUE.equals(modListInfo.second)) {
|
||||
declaration.rollbackTo();
|
||||
return null;
|
||||
}
|
||||
@@ -408,17 +408,6 @@ public class DeclarationParser {
|
||||
|
||||
eatBrackets(builder, constructor, "expected.semicolon");
|
||||
|
||||
if (builder.getTokenType() == JavaTokenType.AT) {
|
||||
final PsiBuilder.Marker receiver = builder.mark();
|
||||
final PsiBuilder.Marker annotations = parseAnnotations(builder);
|
||||
if (annotations != null) {
|
||||
done(receiver, JavaElementType.METHOD_RECEIVER);
|
||||
}
|
||||
else {
|
||||
receiver.drop();
|
||||
}
|
||||
}
|
||||
|
||||
myParser.getReferenceParser().parseReferenceList(builder, JavaTokenType.THROWS_KEYWORD, JavaElementType.THROWS_LIST, JavaTokenType.COMMA);
|
||||
|
||||
final boolean hasDefault = expect(builder, JavaTokenType.DEFAULT_KEYWORD);
|
||||
@@ -565,8 +554,6 @@ public class DeclarationParser {
|
||||
}
|
||||
}
|
||||
|
||||
// todo: false positive
|
||||
//noinspection ConstantConditions
|
||||
if (invalidElements != null) {
|
||||
invalidElements.error(errorMessage);
|
||||
}
|
||||
@@ -608,7 +595,7 @@ public class DeclarationParser {
|
||||
typeInfo = myParser.getReferenceParser().parseTypeInfo(builder, flags);
|
||||
|
||||
if (typeInfo == null) {
|
||||
if (modListInfo.second) {
|
||||
if (Boolean.TRUE.equals(modListInfo.second)) {
|
||||
param.rollbackTo();
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -432,10 +432,7 @@ public class ClsMethodImpl extends ClsRepositoryPsiElement<PsiMethodStub> implem
|
||||
public SearchScope getUseScope() {
|
||||
return PsiImplUtil.getMemberUseScope(this);
|
||||
}
|
||||
@Override
|
||||
public PsiMethodReceiver getMethodReceiver() {
|
||||
return null; //todo parse cls
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiType getReturnTypeNoResolve() {
|
||||
return getReturnType();
|
||||
@@ -445,5 +442,4 @@ public class ClsMethodImpl extends ClsRepositoryPsiElement<PsiMethodStub> implem
|
||||
protected boolean isVisibilitySupported() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -256,11 +256,6 @@ public class LightMethod extends LightElement implements PsiMethod {
|
||||
return getContainingClass();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiMethodReceiver getMethodReceiver() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiType getReturnTypeNoResolve() {
|
||||
return getReturnType();
|
||||
|
||||
@@ -32,7 +32,6 @@ import com.intellij.psi.impl.java.stubs.JavaStubElementTypes;
|
||||
import com.intellij.psi.impl.java.stubs.PsiMethodStub;
|
||||
import com.intellij.psi.impl.source.tree.ChildRole;
|
||||
import com.intellij.psi.impl.source.tree.CompositeElement;
|
||||
import com.intellij.psi.impl.source.tree.JavaElementType;
|
||||
import com.intellij.psi.impl.source.tree.JavaSharedImplUtil;
|
||||
import com.intellij.psi.javadoc.PsiDocComment;
|
||||
import com.intellij.psi.scope.PsiScopeProcessor;
|
||||
@@ -159,13 +158,6 @@ public class PsiMethodImpl extends JavaStubPsiElement<PsiMethodStub> implements
|
||||
return PsiSuperMethodImplUtil.getHierarchicalMethodSignature(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiMethodReceiver getMethodReceiver() {
|
||||
ASTNode node = getNode().findChildByType(JavaElementType.METHOD_RECEIVER);
|
||||
if (node == null) return null;
|
||||
return (PsiMethodReceiver)node.getPsi();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiElement setName(@NotNull String name) throws IncorrectOperationException{
|
||||
PsiImplUtil.setName(getNameIdentifier(), name);
|
||||
|
||||
@@ -1,130 +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;
|
||||
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.source.tree.CompositePsiElement;
|
||||
import com.intellij.psi.impl.source.tree.ElementType;
|
||||
import com.intellij.psi.impl.source.tree.JavaElementType;
|
||||
import com.intellij.psi.impl.PsiImplUtil;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author cdr
|
||||
*/
|
||||
public class PsiMethodReceiverImpl extends CompositePsiElement implements PsiMethodReceiver {
|
||||
public PsiMethodReceiverImpl() {
|
||||
super(JavaElementType.METHOD_RECEIVER);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public PsiElement getDeclarationScope() {
|
||||
return getParent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVarArgs() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public PsiAnnotation[] getAnnotations() {
|
||||
return getChildrenAsPsiElements(ElementType.ANNOTATIONS, PsiAnnotation.ARRAY_FACTORY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiAnnotation findAnnotation(@NotNull @NonNls String qualifiedName) {
|
||||
return PsiImplUtil.findAnnotation(this, qualifiedName);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public PsiAnnotation addAnnotation(@NotNull @NonNls String qualifiedName) {
|
||||
throw new IncorrectOperationException();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public PsiType getType() {
|
||||
return JavaPsiFacade.getElementFactory(getProject()).createType(((PsiMethod)getParent()).getContainingClass());
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiTypeElement getTypeElement() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiExpression getInitializer() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasInitializer() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void normalizeDeclaration() throws IncorrectOperationException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object computeConstantValue() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiIdentifier getNameIdentifier() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "this";
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiElement setName(@NonNls @NotNull String name) throws IncorrectOperationException {
|
||||
throw new IncorrectOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiModifierList getModifierList() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasModifierProperty(@NonNls @NotNull String name) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public PsiAnnotation[] getApplicableAnnotations() {
|
||||
return getAnnotations();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiType getTypeNoResolve() {
|
||||
return getType();
|
||||
}
|
||||
}
|
||||
@@ -133,7 +133,6 @@ public interface JavaElementType {
|
||||
IElementType LABELED_STATEMENT = new JavaCompositeElementType("LABELED_STATEMENT", PsiLabeledStatementImpl.class);
|
||||
IElementType ASSERT_STATEMENT = new JavaCompositeElementType("ASSERT_STATEMENT", PsiAssertStatementImpl.class);
|
||||
IElementType ANNOTATION_ARRAY_INITIALIZER = new JavaCompositeElementType("ANNOTATION_ARRAY_INITIALIZER", PsiArrayInitializerMemberValueImpl.class);
|
||||
IElementType METHOD_RECEIVER = new JavaCompositeElementType("METHOD_RECEIVER", PsiMethodReceiverImpl.class);
|
||||
|
||||
class ICodeBlockElementType extends IErrorCounterReparseableElementType implements ICompositeElementType, ILightLazyParseableElementType {
|
||||
private ICodeBlockElementType() {
|
||||
|
||||
+4
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -123,7 +123,9 @@ public class PsiAnnotationImpl extends JavaStubPsiElement<PsiAnnotationStub> imp
|
||||
if (parent instanceof PsiTypeElement) {
|
||||
return ((PsiTypeElement)parent).getOwner(this);
|
||||
}
|
||||
if (parent instanceof PsiMethodReceiver || parent instanceof PsiTypeParameter) return (PsiAnnotationOwner)parent;
|
||||
if (parent instanceof PsiTypeParameter) {
|
||||
return (PsiAnnotationOwner)parent;
|
||||
}
|
||||
PsiElement member = parent.getParent();
|
||||
String[] elementTypeFields = getApplicableElementTypeFields(member);
|
||||
if (elementTypeFields == null) return null;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class C<@D T extends @F Object> extends @F Object {
|
||||
@F int @F[] methodf() @F throws @F Exception {
|
||||
@F int @F[] methodf() throws @F Exception {
|
||||
a = this instanceof @F C;
|
||||
C<@F @G C> c = new @Q C<@F C>();
|
||||
c = (@F Object)c;
|
||||
|
||||
@@ -93,16 +93,6 @@ PsiJavaFile:TypeAnno.java
|
||||
PsiJavaToken:LPARENTH('(')
|
||||
PsiJavaToken:RPARENTH(')')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(METHOD_RECEIVER)
|
||||
PsiAnnotation
|
||||
PsiJavaToken:AT('@')
|
||||
PsiJavaCodeReferenceElement:F
|
||||
PsiIdentifier:F('F')
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiAnnotationParameterList
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
PsiReferenceList
|
||||
PsiKeyword:throws('throws')
|
||||
PsiWhiteSpace(' ')
|
||||
|
||||
@@ -93,16 +93,6 @@ PsiJavaFile:TypeAnno.java
|
||||
PsiJavaToken:LPARENTH('(')
|
||||
PsiJavaToken:RPARENTH(')')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(METHOD_RECEIVER)
|
||||
PsiAnnotation
|
||||
PsiJavaToken:AT('@')
|
||||
PsiJavaCodeReferenceElement:F
|
||||
PsiIdentifier:F('F')
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiAnnotationParameterList
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
PsiReferenceList
|
||||
PsiKeyword:throws('throws')
|
||||
PsiWhiteSpace(' ')
|
||||
|
||||
+1
-13
@@ -16,8 +16,6 @@
|
||||
package com.intellij.lang.java.parser.annotationParsing;
|
||||
|
||||
import com.intellij.lang.java.parser.JavaParsingTestCase;
|
||||
import com.intellij.psi.PsiErrorElement;
|
||||
import com.intellij.psi.PsiRecursiveElementVisitor;
|
||||
|
||||
/**
|
||||
* @author ven
|
||||
@@ -40,15 +38,5 @@ public class AnnotationParsingTest extends JavaParsingTestCase {
|
||||
public void testQualifiedAnnotation() { doTest(true); }
|
||||
public void testEnumSmartTypeCompletion() { doTest(true); }
|
||||
public void testErrors() { doTest(true); }
|
||||
|
||||
public void testTypeAnno() {
|
||||
doTest(true);
|
||||
myFile.accept(new PsiRecursiveElementVisitor() {
|
||||
@Override
|
||||
public void visitErrorElement(PsiErrorElement element) {
|
||||
fail(element.getErrorDescription());
|
||||
super.visitErrorElement(element);
|
||||
}
|
||||
});
|
||||
}
|
||||
public void testTypeAnno() { doTest(true); }
|
||||
}
|
||||
|
||||
+1
-1
@@ -40,7 +40,7 @@ public class DeclarationParserTest extends JavaParsingTestCase {
|
||||
" @Preliminary(a=A.B\n#, b=c) public class TimeTravel {} }", false, false); }
|
||||
public void testTypeAnno() {
|
||||
doParserTest("{ class C<@D T extends @F Object> extends @F Object {\n" +
|
||||
" @F int @F[] method() @F throws @F Exception {\n" +
|
||||
" @F int @F[] method() throws @F Exception {\n" +
|
||||
" a = this instanceof @F C;\n" +
|
||||
" C<@F @G C> c = new @Q C<@F C>();\n" +
|
||||
" c = (@F Object)c;\n" +
|
||||
|
||||
-4
@@ -528,10 +528,6 @@ public abstract class GrMethodBaseImpl extends GrStubElementBase<GrMethodStub> i
|
||||
return visitor.getResult();
|
||||
}
|
||||
|
||||
public PsiMethodReceiver getMethodReceiver() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public PsiType getReturnTypeNoResolve() {
|
||||
if (isConstructor()) return null;
|
||||
|
||||
|
||||
-5
@@ -439,11 +439,6 @@ public class GrLightMethodBuilder extends LightElement implements GrMethod, Ori
|
||||
return getContainingFile();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiMethodReceiver getMethodReceiver() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiType getReturnTypeNoResolve() {
|
||||
return getReturnType();
|
||||
|
||||
-4
@@ -227,10 +227,6 @@ public class GrDynamicMethodImpl extends LightElement implements GrMethod {
|
||||
return myMethod.getHierarchicalMethodSignature();
|
||||
}
|
||||
|
||||
public PsiMethodReceiver getMethodReceiver() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public PsiType getReturnTypeNoResolve() {
|
||||
return myMethod.getReturnTypeNoResolve();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user