mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Groovy: remove redundant GrDefaultAnnotationValue psi.
This commit is contained in:
@@ -1493,13 +1493,13 @@ public class GroovyAnnotator extends GroovyElementVisitor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitDefaultAnnotationValue(GrDefaultAnnotationValue defaultAnnotationValue) {
|
||||
final GrAnnotationMemberValue value = defaultAnnotationValue.getDefaultValue();
|
||||
public void visitAnnotationMethod(GrAnnotationMethod annotationMethod) {
|
||||
super.visitAnnotationMethod(annotationMethod);
|
||||
|
||||
final GrAnnotationMemberValue value = annotationMethod.getDefaultValue();
|
||||
if (value == null) return;
|
||||
|
||||
final PsiElement parent = defaultAnnotationValue.getParent();
|
||||
assert parent instanceof GrAnnotationMethod;
|
||||
final PsiType type = ((GrAnnotationMethod)parent).getReturnType();
|
||||
final PsiType type = annotationMethod.getReturnType();
|
||||
|
||||
Map<PsiElement, String> errors = ContainerUtil.newHashMap();
|
||||
CustomAnnotationChecker.checkAnnotationValueByType(errors, value, type, false);
|
||||
|
||||
+9
-6
@@ -36,10 +36,7 @@ import org.jetbrains.plugins.groovy.lang.psi.GroovyFileBase;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.GrListOrMap;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.GrThrowsClause;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.annotation.GrAnnotation;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.annotation.GrAnnotationArgumentList;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.annotation.GrAnnotationArrayInitializer;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.annotation.GrAnnotationNameValuePair;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.annotation.*;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.*;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrNamedArgument;
|
||||
@@ -55,6 +52,7 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrExtendsCla
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrImplementsClause;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinitionBody;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrAnnotationMethod;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMethod;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.types.GrCodeReferenceElement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.types.GrTypeArgumentList;
|
||||
@@ -407,8 +405,13 @@ public class GroovyIndentProcessor extends GroovyElementVisitor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitDefaultAnnotationValue(GrDefaultAnnotationValue defaultAnnotationValue) {
|
||||
myResult = Indent.getContinuationIndent();
|
||||
public void visitAnnotationMethod(GrAnnotationMethod annotationMethod) {
|
||||
if (myChild instanceof GrAnnotationMemberValue) {
|
||||
myResult = Indent.getContinuationIndent();
|
||||
}
|
||||
else {
|
||||
super.visitAnnotationMethod(annotationMethod);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
-1
@@ -69,6 +69,7 @@ import org.jetbrains.plugins.groovy.lang.psi.impl.PsiImplUtil;
|
||||
import static org.jetbrains.plugins.groovy.GroovyFileType.GROOVY_LANGUAGE;
|
||||
import static org.jetbrains.plugins.groovy.formatter.models.spacing.SpacingTokens.*;
|
||||
import static org.jetbrains.plugins.groovy.formatter.models.spacing.SpacingTokens.GROOVY_DOC_COMMENT;
|
||||
import static org.jetbrains.plugins.groovy.formatter.models.spacing.SpacingTokens.kDEFAULT;
|
||||
import static org.jetbrains.plugins.groovy.formatter.models.spacing.SpacingTokens.kIN;
|
||||
import static org.jetbrains.plugins.groovy.formatter.models.spacing.SpacingTokens.mCOMMA;
|
||||
import static org.jetbrains.plugins.groovy.formatter.models.spacing.SpacingTokens.mELVIS;
|
||||
@@ -684,7 +685,7 @@ public class GroovySpacingProcessor extends GroovyElementVisitor {
|
||||
|
||||
@Override
|
||||
public void visitAnnotationMethod(GrAnnotationMethod annotationMethod) {
|
||||
if (myType2 == DEFAULT_ANNOTATION_VALUE) {
|
||||
if (myType2 == kDEFAULT) {
|
||||
createSpaceInCode(true);
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -104,8 +104,6 @@ public class GroovyPsiCreator implements GroovyElementTypes {
|
||||
if (elem == ANNOTATION_ARRAY_INITIALIZER) return new GrAnnotationArrayInitializerImpl(node);
|
||||
if (elem == ANNOTATION_MEMBER_VALUE_PAIR) return new GrAnnotationNameValuePairImpl(node);
|
||||
|
||||
if (elem == DEFAULT_ANNOTATION_VALUE) return new GrDefaultAnnotationValueImpl(node);
|
||||
|
||||
//throws
|
||||
if (elem == THROW_CLAUSE) return new GrThrowsClauseImpl(node);
|
||||
|
||||
|
||||
+1
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -152,15 +152,12 @@ public class VariableDefinitions implements GroovyElementTypes {
|
||||
}
|
||||
|
||||
if (isAnnotationMember && builder.getTokenType() == kDEFAULT) {
|
||||
PsiBuilder.Marker defaultValueMarker = builder.mark();
|
||||
ParserUtils.getToken(builder, kDEFAULT);
|
||||
ParserUtils.getToken(builder, mNLS);
|
||||
|
||||
if (!AnnotationArguments.parseAnnotationMemberValueInitializer(builder, parser)) {
|
||||
builder.error(GroovyBundle.message("annotation.initializer.expected"));
|
||||
}
|
||||
|
||||
defaultValueMarker.done(DEFAULT_ANNOTATION_VALUE);
|
||||
}
|
||||
|
||||
if (ParserUtils.lookAhead(builder, mNLS, kTHROWS) || ParserUtils.lookAhead(builder, mNLS, mLCURLY)) {
|
||||
|
||||
@@ -296,10 +296,6 @@ public abstract class GroovyElementVisitor {
|
||||
visitMethod(annotationMethod);
|
||||
}
|
||||
|
||||
public void visitDefaultAnnotationValue(GrDefaultAnnotationValue defaultAnnotationValue) {
|
||||
visitElement(defaultAnnotationValue);
|
||||
}
|
||||
|
||||
public void visitMethod(GrMethod method) {
|
||||
visitElement(method);
|
||||
}
|
||||
|
||||
-30
@@ -1,30 +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 org.jetbrains.plugins.groovy.lang.psi.api.statements;
|
||||
|
||||
import com.intellij.psi.PsiAnnotationMemberValue;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.annotation.GrAnnotationMemberValue;
|
||||
|
||||
/**
|
||||
* User: Dmitry.Krasilschikov
|
||||
* Date: 04.06.2007
|
||||
*/
|
||||
public interface GrDefaultAnnotationValue extends GroovyPsiElement, PsiAnnotationMemberValue {
|
||||
@Nullable
|
||||
GrAnnotationMemberValue getDefaultValue();
|
||||
}
|
||||
+4
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -17,13 +17,14 @@ package org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members;
|
||||
|
||||
import com.intellij.psi.PsiAnnotationMethod;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrDefaultAnnotationValue;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.annotation.GrAnnotationMemberValue;
|
||||
|
||||
/**
|
||||
* User: Dmitry.Krasilschikov
|
||||
* Date: 04.06.2007
|
||||
*/
|
||||
public interface GrAnnotationMethod extends GrMethod, PsiAnnotationMethod {
|
||||
|
||||
@Nullable
|
||||
GrDefaultAnnotationValue getDefaultValue();
|
||||
GrAnnotationMemberValue getDefaultValue();
|
||||
}
|
||||
|
||||
+2
-4
@@ -205,9 +205,7 @@ public class GroovyExpectedTypesProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitDefaultAnnotationValue(GrDefaultAnnotationValue defaultAnnotationValue) {
|
||||
final GrAnnotationMethod method = ((GrAnnotationMethod)defaultAnnotationValue.getParent());
|
||||
|
||||
public void visitAnnotationMethod(GrAnnotationMethod method) {
|
||||
PsiType type = method.getReturnType();
|
||||
if (type != null && isAcceptableAnnotationValueType(type)) {
|
||||
myResult = createSimpleSubTypeResult(type);
|
||||
@@ -216,7 +214,7 @@ public class GroovyExpectedTypesProvider {
|
||||
|
||||
@Override
|
||||
public void visitAnnotationArrayInitializer(GrAnnotationArrayInitializer arrayInitializer) {
|
||||
final GrAnnotationNameValuePair nameValuePair = PsiTreeUtil.getParentOfType(arrayInitializer, GrAnnotationNameValuePair.class, true, GrDefaultAnnotationValue.class);
|
||||
final GrAnnotationNameValuePair nameValuePair = PsiTreeUtil.getParentOfType(arrayInitializer, GrAnnotationNameValuePair.class, true, GrAnnotationMethod.class);
|
||||
if (nameValuePair != null) {
|
||||
|
||||
final PsiClass annot = ResolveUtil.resolveAnnotation(arrayInitializer);
|
||||
|
||||
-47
@@ -1,47 +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 org.jetbrains.plugins.groovy.lang.psi.impl.statements;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyElementVisitor;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.annotation.GrAnnotationMemberValue;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrDefaultAnnotationValue;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.GroovyPsiElementImpl;
|
||||
|
||||
/**
|
||||
* User: Dmitry.Krasilschikov
|
||||
* Date: 04.06.2007
|
||||
*/
|
||||
public class GrDefaultAnnotationValueImpl extends GroovyPsiElementImpl implements GrDefaultAnnotationValue {
|
||||
|
||||
public GrDefaultAnnotationValueImpl(@NotNull ASTNode node) {
|
||||
super(node);
|
||||
}
|
||||
|
||||
public void accept(GroovyElementVisitor visitor) {
|
||||
visitor.visitDefaultAnnotationValue(this);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "Default annotation value";
|
||||
}
|
||||
|
||||
@Override
|
||||
public GrAnnotationMemberValue getDefaultValue() {
|
||||
return findChildByClass(GrAnnotationMemberValue.class);
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.groovy.extensions.NamedArgumentDescriptor;
|
||||
import org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyElementVisitor;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrDefaultAnnotationValue;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.annotation.GrAnnotationMemberValue;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrAnnotationMethod;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.stubs.GrMethodStub;
|
||||
|
||||
@@ -54,7 +54,7 @@ public class GrAnnotationMethodImpl extends GrMethodBaseImpl implements GrAnnota
|
||||
}
|
||||
|
||||
@Override
|
||||
public GrDefaultAnnotationValue getDefaultValue() {
|
||||
return findChildByClass(GrDefaultAnnotationValue.class);
|
||||
public GrAnnotationMemberValue getDefaultValue() {
|
||||
return findChildByClass(GrAnnotationMemberValue.class);
|
||||
}
|
||||
}
|
||||
|
||||
+4
-8
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -32,7 +32,6 @@ import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.annotation.GrAnnotationMemberValue;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.signatures.GrClosureSignature;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrDefaultAnnotationValue;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrStatement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariableDeclaration;
|
||||
@@ -139,13 +138,10 @@ public class ClassItemGeneratorImpl implements ClassItemGenerator {
|
||||
GenerationUtil.writeParameterList(builder, method.getParameterList().getParameters(), classNameProvider, context);
|
||||
|
||||
if (method instanceof GrAnnotationMethod) {
|
||||
GrDefaultAnnotationValue defaultAnnotationValue = ((GrAnnotationMethod)method).getDefaultValue();
|
||||
if (defaultAnnotationValue!=null) {
|
||||
GrAnnotationMemberValue defaultValue = ((GrAnnotationMethod)method).getDefaultValue();
|
||||
if (defaultValue != null) {
|
||||
builder.append("default ");
|
||||
GrAnnotationMemberValue defaultValue = defaultAnnotationValue.getDefaultValue();
|
||||
if (defaultValue != null) {
|
||||
defaultValue.accept(new AnnotationGenerator(builder, context));
|
||||
}
|
||||
defaultValue.accept(new AnnotationGenerator(builder, context));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,14 +31,13 @@ Groovy script
|
||||
<empty list>
|
||||
PsiElement())(')')
|
||||
PsiWhiteSpace(' ')
|
||||
Default annotation value
|
||||
PsiElement(default)('default')
|
||||
PsiWhiteSpace(' ')
|
||||
Annotation array initializer
|
||||
PsiElement([)('[')
|
||||
Literal
|
||||
PsiElement(Integer)('8')
|
||||
PsiElement(])(']')
|
||||
PsiElement(default)('default')
|
||||
PsiWhiteSpace(' ')
|
||||
Annotation array initializer
|
||||
PsiElement([)('[')
|
||||
Literal
|
||||
PsiElement(Integer)('8')
|
||||
PsiElement(])(']')
|
||||
Throw clause
|
||||
<empty list>
|
||||
PsiElement(;)(';')
|
||||
|
||||
@@ -34,15 +34,14 @@ Groovy script
|
||||
<empty list>
|
||||
PsiElement())(')')
|
||||
PsiWhiteSpace(' ')
|
||||
Default annotation value
|
||||
PsiElement(default)('default')
|
||||
PsiWhiteSpace(' ')
|
||||
Annotation
|
||||
PsiElement(@)('@')
|
||||
Reference element
|
||||
PsiElement(identifier)('Bar')
|
||||
Annotation arguments
|
||||
<empty list>
|
||||
PsiElement(default)('default')
|
||||
PsiWhiteSpace(' ')
|
||||
Annotation
|
||||
PsiElement(@)('@')
|
||||
Reference element
|
||||
PsiElement(identifier)('Bar')
|
||||
Annotation arguments
|
||||
<empty list>
|
||||
Throw clause
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
|
||||
@@ -34,11 +34,10 @@ Groovy script
|
||||
<empty list>
|
||||
PsiElement())(')')
|
||||
PsiWhiteSpace(' ')
|
||||
Default annotation value
|
||||
PsiElement(default)('default')
|
||||
PsiWhiteSpace(' ')
|
||||
Literal
|
||||
PsiElement(Integer)('5')
|
||||
PsiElement(default)('default')
|
||||
PsiWhiteSpace(' ')
|
||||
Literal
|
||||
PsiElement(Integer)('5')
|
||||
Throw clause
|
||||
<empty list>
|
||||
PsiElement(new line)('\n')
|
||||
|
||||
Reference in New Issue
Block a user