make synthetic enum valueOf/values methods part of PsiClass#getMethods

because all other synthetic methods from records and plugins are also there
inspired by IDEA-CR-57031

GitOrigin-RevId: 9a8b345adaded83fe13980a28db5d9f9acc7450d
This commit is contained in:
Peter Gromov
2020-01-21 06:38:24 +00:00
committed by intellij-monorepo-bot
parent f188b0bb2b
commit 6d71b92a62
29 changed files with 132 additions and 106 deletions
@@ -34,6 +34,7 @@ import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.JBTreeTraverser;
import gnu.trove.THashMap;
import gnu.trove.THashSet;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -48,8 +49,6 @@ import java.util.concurrent.ConcurrentMap;
public class PsiClassImplUtil {
private static final Logger LOG = Logger.getInstance(PsiClassImplUtil.class);
private static final Key<ParameterizedCachedValue<Map<GlobalSearchScope, MembersMap>, PsiClass>> MAP_IN_CLASS_KEY = Key.create("MAP_KEY");
private static final String VALUES_METHOD = "values";
private static final String VALUE_OF_METHOD = "valueOf";
private PsiClassImplUtil() { }
@@ -370,22 +369,15 @@ public class PsiClassImplUtil {
}
}
/**
* @deprecated synthetic enum methods are included into {@link PsiClass#getMethods()}
*/
@SuppressWarnings("unused")
@Deprecated
@ApiStatus.ScheduledForRemoval(inVersion = "2020.2")
public static boolean processDeclarationsInEnum(@NotNull PsiScopeProcessor processor,
@NotNull ResolveState state,
@NotNull ClassInnerStuffCache innerStuffCache) {
ElementClassHint classHint = processor.getHint(ElementClassHint.KEY);
if (classHint == null || classHint.shouldProcess(ElementClassHint.DeclarationKind.METHOD)) {
NameHint nameHint = processor.getHint(NameHint.KEY);
if (nameHint == null || VALUES_METHOD.equals(nameHint.getName(state))) {
PsiMethod method = innerStuffCache.getValuesMethod();
if (method != null && !processor.execute(method, ResolveState.initial())) return false;
}
if (nameHint == null || VALUE_OF_METHOD.equals(nameHint.getName(state))) {
PsiMethod method = innerStuffCache.getValueOfMethod();
if (method != null && !processor.execute(method, ResolveState.initial())) return false;
}
}
return true;
}
@@ -6,12 +6,13 @@ import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.util.Pair;
import com.intellij.psi.*;
import com.intellij.psi.impl.source.HierarchicalMethodSignatureImpl;
import com.intellij.psi.impl.source.PsiClassImpl;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.search.searches.DeepestSuperMethodsSearch;
import com.intellij.psi.search.searches.SuperMethodsSearch;
import com.intellij.psi.util.*;
import com.intellij.util.*;
import com.intellij.util.NotNullFunction;
import com.intellij.util.Processor;
import com.intellij.util.SmartList;
import com.intellij.util.containers.ConcurrentFactoryMap;
import com.intellij.util.containers.hash.EqualityPolicy;
import com.intellij.util.containers.hash.LinkedHashMap;
@@ -158,13 +159,6 @@ public class PsiSuperMethodImplUtil {
});
PsiMethod[] methods = nameHint == null ? aClass.getMethods() : aClass.findMethodsByName(nameHint, false);
if ((nameHint == null || "values".equals(nameHint)) && aClass instanceof PsiClassImpl) {
final PsiMethod valuesMethod = ((PsiClassImpl)aClass).getValuesMethod();
if (valuesMethod != null) {
methods = ArrayUtil.append(methods, valuesMethod);
}
}
for (PsiMethod method : methods) {
if (!method.isValid()) {
throw new PsiInvalidElementAccessException(method, "class.valid=" + aClass.isValid() + "; name=" + method.getName());
@@ -459,10 +459,6 @@ public class ClsClassImpl extends ClsMemberImpl<PsiClassStub<?>> implements PsiE
@NotNull ResolveState state,
PsiElement lastParent,
@NotNull PsiElement place) {
if (isEnum()) {
if (!PsiClassImplUtil.processDeclarationsInEnum(processor, state, myInnersCache)) return false;
}
LanguageLevel level = processor instanceof MethodsProcessor ? ((MethodsProcessor)processor).getLanguageLevel() : PsiUtil.getLanguageLevel(place);
return PsiClassImplUtil.processDeclarationsInClass(this, processor, state, null, lastParent, place, level, false);
}
@@ -82,12 +82,12 @@ public class ClassInnerStuffCache {
}
@Nullable
public PsiMethod getValuesMethod() {
PsiMethod getValuesMethod() {
return myClass.isEnum() && myClass.getName() != null ? CachedValuesManager.getCachedValue(myClass, () -> makeResult(makeValuesMethod())) : null;
}
@Nullable
public PsiMethod getValueOfMethod() {
private PsiMethod getValueOfMethod() {
return myClass.isEnum() && myClass.getName() != null ? CachedValuesManager.getCachedValue(myClass, () -> makeResult(makeValueOfMethod())) : null;
}
@@ -108,6 +108,10 @@ public class ClassInnerStuffCache {
private PsiMethod @NotNull [] calcMethods() {
List<PsiMethod> own = myClass.getOwnMethods();
List<PsiMethod> ext = PsiAugmentProvider.collectAugments(myClass, PsiMethod.class);
if (myClass.isEnum()) {
ext.add(getValuesMethod());
ext.add(getValueOfMethod());
}
return ArrayUtil.mergeCollections(own, ext, PsiMethod.ARRAY_FACTORY);
}
@@ -472,10 +472,6 @@ public class PsiClassImpl extends JavaStubPsiElement<PsiClassStub<?>> implements
@Override
public boolean processDeclarations(@NotNull PsiScopeProcessor processor, @NotNull ResolveState state, PsiElement lastParent, @NotNull PsiElement place) {
if (isEnum()) {
if (!PsiClassImplUtil.processDeclarationsInEnum(processor, state, myInnersCache)) return false;
}
LanguageLevel level = PsiUtil.getLanguageLevel(place);
return PsiClassImplUtil.processDeclarationsInClass(this, processor, state, null, lastParent, place, level, false);
}
@@ -41,7 +41,7 @@ enum Operation {
enum enumWithTypeParameterInValueOf {
;
<error descr="'valueOf(String)' is already defined in 'enumWithTypeParameterInValueOf'">static <T> void valueOf(String s)</error> {}
<error descr="'valueOf(String)' clashes with 'valueOf(String)'; both methods have same erasure"><error descr="'valueOf(String)' is already defined in 'enumWithTypeParameterInValueOf'">static <T> void valueOf(String s)</error></error> {}
}
<error descr="There is no default constructor available in 'Operation'">class exte extends <error descr="Cannot inherit from enum 'Operation'">Operation</error></error> {
@@ -141,7 +141,9 @@ public class BytecodeAnalysisIntegrationTest extends LightJavaCodeInsightFixture
protected void visitSubPackage(PsiPackage aPackage, PsiClass[] classes) {
for (PsiClass aClass : classes) {
for (PsiMethod method : aClass.getMethods()) {
checkMethodAnnotations(method, diffs);
if (method.isPhysical()) {
checkMethodAnnotations(method, diffs);
}
}
for (PsiField field : aClass.getFields()) {
checkFieldAnnotations(field, diffs);
@@ -451,9 +451,8 @@ public class JavaMatchingVisitor extends JavaElementVisitor {
}
}
final PsiField[] fields = patternClass.getFields();
if (fields.length > 0) {
PsiField[] fields = PsiTreeUtil.getChildrenOfType(patternClass, PsiField.class);
if (fields != null) {
final PsiField[] fields2 = javaPattern.isRequestsSuperFields() ?
matchClass.getAllFields() :
matchClass.getFields();
@@ -463,9 +462,8 @@ public class JavaMatchingVisitor extends JavaElementVisitor {
}
}
final PsiMethod[] methods = patternClass.getMethods();
if (methods.length > 0) {
PsiMethod[] methods = PsiTreeUtil.getChildrenOfType(patternClass, PsiMethod.class);
if (methods != null) {
final PsiMethod[] methods2 = javaPattern.isRequestsSuperMethods() ?
matchClass.getAllMethods() :
matchClass.getMethods();
@@ -475,9 +473,8 @@ public class JavaMatchingVisitor extends JavaElementVisitor {
}
}
final PsiClass[] nestedClasses = patternClass.getInnerClasses();
if (nestedClasses.length > 0) {
PsiClass[] nestedClasses = PsiTreeUtil.getChildrenOfType(patternClass, PsiClass.class);
if (nestedClasses != null) {
final PsiClass[] nestedClasses2 = javaPattern.isRequestsSuperInners() ?
matchClass.getAllInnerClasses() :
matchClass.getInnerClasses();
@@ -189,16 +189,8 @@ public class EmptyClassInspection extends BaseInspection {
if (aClass instanceof PsiTypeParameter) {
return;
}
final PsiMethod[] constructors = aClass.getConstructors();
if (constructors.length > 0) {
return;
}
final PsiMethod[] methods = aClass.getMethods();
if (methods.length > 0) {
return;
}
final PsiField[] fields = aClass.getFields();
if (fields.length > 0) {
if (PsiTreeUtil.getChildOfType(aClass, PsiMethod.class) != null ||
PsiTreeUtil.getChildOfType(aClass, PsiField.class) != null) {
return;
}
final PsiClassInitializer[] initializers = aClass.getInitializers();
@@ -2,17 +2,13 @@
package org.jetbrains.plugins.groovy.lang.psi.impl.statements.typedef;
import com.intellij.lang.ASTNode;
import com.intellij.openapi.util.Key;
import com.intellij.psi.*;
import com.intellij.psi.impl.PsiManagerEx;
import com.intellij.psi.impl.light.LightMethodBuilder;
import com.intellij.psi.scope.ElementClassHint;
import com.intellij.psi.scope.NameHint;
import com.intellij.psi.scope.PsiScopeProcessor;
import com.intellij.psi.util.CachedValueProvider;
import com.intellij.psi.util.CachedValuesManager;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.groovy.GroovyLanguage;
import org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes;
import org.jetbrains.plugins.groovy.lang.parser.GroovyEmptyStubElementTypes;
@@ -25,7 +21,9 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrEn
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrEnumConstantList;
import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil;
import org.jetbrains.plugins.groovy.lang.psi.stubs.GrTypeDefinitionStub;
import org.jetbrains.plugins.groovy.lang.resolve.ResolveUtil;
import java.util.Arrays;
import java.util.List;
import static com.intellij.psi.CommonClassNames.JAVA_LANG_ENUM;
@@ -35,6 +33,8 @@ import static com.intellij.psi.CommonClassNames.JAVA_LANG_ENUM;
*/
public class GrEnumTypeDefinitionImpl extends GrTypeDefinitionImpl implements GrEnumTypeDefinition {
private static final @NotNull Key<Boolean> PREDEFINED_ENUM_METHOD = Key.create("PREDEFINED_ENUM_METHOD");
public GrEnumTypeDefinitionImpl(@NotNull ASTNode node) {
super(node);
}
@@ -79,55 +79,40 @@ public class GrEnumTypeDefinitionImpl extends GrTypeDefinitionImpl implements Gr
return TypesUtil.createTypeByFQClassName(JAVA_LANG_ENUM, this);
}
@Override
public boolean processDeclarations(@NotNull PsiScopeProcessor processor,
@NotNull ResolveState state,
@Nullable PsiElement lastParent,
@NotNull PsiElement place) {
if (ResolveUtil.shouldProcessMethods(processor.getHint(ElementClassHint.KEY))) {
final NameHint nameHint = processor.getHint(NameHint.KEY);
final String name = nameHint == null ? null : nameHint.getName(state);
for (PsiMethod method : getDefEnumMethods()) {
if (name == null || name.equals(method.getName())) {
if (!processor.execute(method, state)) return false;
}
}
}
return super.processDeclarations(processor, state, lastParent, place);
}
private PsiMethod[] getDefEnumMethods() {
return CachedValuesManager.getCachedValue(this, () -> {
PsiMethod[] defMethods = new PsiMethod[4];
final PsiManagerEx manager = getManager();
final PsiElementFactory factory = JavaPsiFacade.getElementFactory(getProject());
final PsiClassType thisType = factory.createType(this);
defMethods[0] = new LightMethodBuilder(manager, GroovyLanguage.INSTANCE, "values")
@ApiStatus.Internal
public List<PsiMethod> getDefEnumMethods() {
PsiManagerEx manager = getManager();
PsiElementFactory factory = JavaPsiFacade.getElementFactory(getProject());
PsiClassType thisType = factory.createType(this);
List<PsiMethod> result = Arrays.asList(
new LightMethodBuilder(manager, GroovyLanguage.INSTANCE, "values")
.setMethodReturnType(new PsiArrayType(thisType))
.setContainingClass(this)
.addModifier(PsiModifier.PUBLIC)
.addModifier(PsiModifier.STATIC);
defMethods[1] = new LightMethodBuilder(manager, GroovyLanguage.INSTANCE, "next")
.addModifier(PsiModifier.STATIC),
new LightMethodBuilder(manager, GroovyLanguage.INSTANCE, "next")
.setMethodReturnType(thisType)
.setContainingClass(this)
.addModifier(PsiModifier.PUBLIC);
defMethods[2] = new LightMethodBuilder(manager, GroovyLanguage.INSTANCE, "previous")
.addModifier(PsiModifier.PUBLIC),
new LightMethodBuilder(manager, GroovyLanguage.INSTANCE, "previous")
.setMethodReturnType(thisType)
.setContainingClass(this)
.addModifier(PsiModifier.PUBLIC);
defMethods[3] = new LightMethodBuilder(manager, GroovyLanguage.INSTANCE, "valueOf")
.addModifier(PsiModifier.PUBLIC),
new LightMethodBuilder(manager, GroovyLanguage.INSTANCE, "valueOf")
.setMethodReturnType(thisType)
.setContainingClass(this)
.addParameter("name", CommonClassNames.JAVA_LANG_STRING)
.addModifier(PsiModifier.PUBLIC)
.addModifier(PsiModifier.STATIC);
.addModifier(PsiModifier.STATIC)
);
for (PsiMethod method : result) {
method.putUserData(PREDEFINED_ENUM_METHOD, true);
}
return result;
}
return CachedValueProvider.Result.create(defMethods, this);
});
public boolean isPredefinedEnumMethod(@NotNull PsiMethod method) {
return method.getUserData(PREDEFINED_ENUM_METHOD) != null;
}
@Override
@@ -14,6 +14,7 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrField
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition
import org.jetbrains.plugins.groovy.lang.psi.impl.PsiImplUtil.getAnnotation
import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil.createType
import org.jetbrains.plugins.groovy.lang.psi.impl.statements.typedef.GrEnumTypeDefinitionImpl
import org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GrLightField
import org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GrLightMethodBuilder
import org.jetbrains.plugins.groovy.lang.psi.util.GrClassImplUtil.*
@@ -217,10 +218,13 @@ internal class TransformationContextImpl(private val myCodeClass: GrTypeDefiniti
internal val transformationResult: TransformationResult
get() = TransformationResult(
methods.toArray(PsiMethod.EMPTY_ARRAY),
(methods + enumMethods()).toArray(PsiMethod.EMPTY_ARRAY),
fields.toArray(GrField.EMPTY_ARRAY),
innerClasses.toArray(PsiClass.EMPTY_ARRAY),
implementsTypes.toArray(PsiClassType.EMPTY_ARRAY),
extendsTypes.toArray(PsiClassType.EMPTY_ARRAY)
)
private fun enumMethods() : List<PsiMethod> =
if (myCodeClass is GrEnumTypeDefinitionImpl) myCodeClass.defEnumMethods else emptyList()
}
@@ -27,6 +27,7 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefini
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrEnumConstant;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMembersDeclaration;
import org.jetbrains.plugins.groovy.lang.psi.api.toplevel.packaging.GrPackageDefinition;
import org.jetbrains.plugins.groovy.lang.psi.impl.statements.typedef.GrEnumTypeDefinitionImpl;
import org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GroovyScriptClass;
import org.jetbrains.plugins.groovy.lang.psi.util.GroovyCommonClassNames;
@@ -140,7 +141,7 @@ public class ClassGenerator {
private void writeAllMethods(StringBuilder text, Collection<PsiMethod> methods, PsiClass aClass) {
for (PsiMethod method : methods) {
if (!shouldBeGenerated(method)) continue;
if (!shouldBeGenerated(method, aClass)) continue;
if (method.isConstructor()) {
classItemGenerator.writeConstructor(text, method, aClass.isEnum());
@@ -153,7 +154,12 @@ public class ClassGenerator {
}
private static boolean shouldBeGenerated(PsiMethod method) {
private static boolean shouldBeGenerated(PsiMethod method, PsiClass containingClass) {
if (containingClass instanceof GrEnumTypeDefinitionImpl &&
((GrEnumTypeDefinitionImpl)containingClass).isPredefinedEnumMethod(method)) {
return false;
}
for (PsiMethod psiMethod : method.findSuperMethods()) {
if (!psiMethod.hasModifierProperty(PsiModifier.ABSTRACT)) {
final PsiType type = method.getReturnType();
@@ -31,6 +31,7 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.*;
import org.jetbrains.plugins.groovy.lang.psi.api.types.GrCodeReferenceElement;
import org.jetbrains.plugins.groovy.lang.psi.impl.signatures.GrClosureSignatureUtil;
import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil;
import org.jetbrains.plugins.groovy.lang.psi.impl.statements.typedef.GrEnumTypeDefinitionImpl;
import org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GroovyScriptClass;
import org.jetbrains.plugins.groovy.transformations.impl.GroovyObjectTransformationSupport;
@@ -19,6 +19,6 @@
<<error descr="Unable to coerce java.lang.Class to javafx.geometry.Insets">Double</error> fx:constant="TYPE"/>
</padding>
<alignment>
<<error descr="Unable to coerce java.lang.Integer to javafx.geometry.Pos">Double</error> fx:constant="SIZE"/>
<Double fx:constant="SIZE"/>
</alignment>
</GridPane>
@@ -8,7 +8,7 @@
</padding>
<Rectangle width="100" height="100">
<VBox.vgrow>
<<error descr="Unable to coerce java.lang.Double to javafx.scene.layout.Priority">Double</error> fx:value="20"/>
<Double fx:value="20"/>
</VBox.vgrow>
</Rectangle>
</fx:root>
@@ -46,3 +46,8 @@ UFile (package = ) [public final enum DeadSwitchEntries {...]
UBreakExpression (label = null) [break] = Nothing(break)
UReturnExpression [return result] = Nothing
USimpleNameReferenceExpression (identifier = result) [result] = (var result = 13)
UMethod (name = values) [public static fun values() : DeadSwitchEntries[] {...}]
UBlockExpression [{...}] = Undetermined
UMethod (name = valueOf) [public static fun valueOf(name: java.lang.String) : DeadSwitchEntries {...}]
UParameter (name = name) [var name: java.lang.String]
UBlockExpression [{...}] = Undetermined
@@ -44,3 +44,8 @@ UFile (package = ) [public final enum DeadSwitchEntriesWithoutBreaks {...]
UBreakExpression (label = null) [break] = Nothing(break)
UReturnExpression [return result] = Nothing
USimpleNameReferenceExpression (identifier = result) [result] = (var result = 66)
UMethod (name = values) [public static fun values() : DeadSwitchEntriesWithoutBreaks[] {...}]
UBlockExpression [{...}] = Undetermined
UMethod (name = valueOf) [public static fun valueOf(name: java.lang.String) : DeadSwitchEntriesWithoutBreaks {...}]
UParameter (name = name) [var name: java.lang.String]
UBlockExpression [{...}] = Undetermined
@@ -21,3 +21,8 @@ UFile (package = ) [public final enum EnumChoice {...]
USimpleNameReferenceExpression (identifier = SECOND) [SECOND] = SECOND (enum entry)
UReturnExpression [return result] = Nothing
USimpleNameReferenceExpression (identifier = result) [result] = (var result = Phi(FIRST (enum entry), SECOND (enum entry)))
UMethod (name = values) [public static fun values() : EnumChoice[] {...}]
UBlockExpression [{...}] = Undetermined
UMethod (name = valueOf) [public static fun valueOf(name: java.lang.String) : EnumChoice {...}]
UParameter (name = name) [var name: java.lang.String]
UBlockExpression [{...}] = Undetermined
@@ -44,3 +44,8 @@ UFile (package = )
UBreakExpression (label = null)
UReturnExpression
USimpleNameReferenceExpression (identifier = result)
UMethod (name = values)
UBlockExpression
UMethod (name = valueOf)
UParameter (name = name)
UBlockExpression
@@ -28,4 +28,8 @@ public final enum EnumSwitch {
return result
}
public static fun values() : EnumSwitch[] {
}
public static fun valueOf(name: java.lang.String) : EnumSwitch {
}
}
@@ -44,3 +44,8 @@ UFile (package = ) [public final enum EnumSwitch {...]
UBreakExpression (label = null) [break] = Nothing(break)
UReturnExpression [return result] = Nothing
USimpleNameReferenceExpression (identifier = result) [result] = (var result = Phi(3, 7, 13, 66))
UMethod (name = values) [public static fun values() : EnumSwitch[] {...}]
UBlockExpression [{...}] = Undetermined
UMethod (name = valueOf) [public static fun valueOf(name: java.lang.String) : EnumSwitch {...}]
UParameter (name = name) [var name: java.lang.String]
UBlockExpression [{...}] = Undetermined
@@ -48,3 +48,8 @@ UFile (package = ) [public final enum EnumSwitchConditionalBreak {...]
UBinaryExpression (operator = +) [newResult + counter] = Undetermined (depending on: (var newResult = 42), (var counter = Undetermined))
USimpleNameReferenceExpression (identifier = newResult) [newResult] = (var newResult = 42)
USimpleNameReferenceExpression (identifier = counter) [counter] = (var counter = Undetermined)
UMethod (name = values) [public static fun values() : EnumSwitchConditionalBreak[] {...}]
UBlockExpression [{...}] = Undetermined
UMethod (name = valueOf) [public static fun valueOf(name: java.lang.String) : EnumSwitchConditionalBreak {...}]
UParameter (name = name) [var name: java.lang.String]
UBlockExpression [{...}] = Undetermined
@@ -42,3 +42,8 @@ UFile (package = ) [public final enum EnumSwitchWithoutBreaks {...]
UBreakExpression (label = null) [break] = Nothing(break)
UReturnExpression [return result] = Nothing
USimpleNameReferenceExpression (identifier = result) [result] = (var result = Phi(3, 66))
UMethod (name = values) [public static fun values() : EnumSwitchWithoutBreaks[] {...}]
UBlockExpression [{...}] = Undetermined
UMethod (name = valueOf) [public static fun valueOf(name: java.lang.String) : EnumSwitchWithoutBreaks {...}]
UParameter (name = name) [var name: java.lang.String]
UBlockExpression [{...}] = Undetermined
@@ -16,3 +16,8 @@ UFile (package = )
UBlockExpression
UReturnExpression
ULiteralExpression (value = null)
UMethod (name = values)
UBlockExpression
UMethod (name = valueOf)
UParameter (name = name)
UBlockExpression
@@ -10,4 +10,8 @@ public enum Style {
public fun getExitAnimation() : java.lang.String {
return null
}
public static fun values() : Style[] {
}
public static fun valueOf(name: java.lang.String) : Style {
}
}
@@ -14,3 +14,8 @@ UFile (package = )
ULocalVariable (name = b)
UAnnotation (fqName = TestAnnotation)
ULiteralExpression (value = 0)
UMethod (name = values)
UBlockExpression
UMethod (name = valueOf)
UParameter (name = name)
UBlockExpression
@@ -7,4 +7,8 @@ final enum Weekday {
public fun foo(@TestAnnotation a: int) : void {
@TestAnnotation var b: int = 0
}
public static fun values() : Weekday[] {
}
public static fun valueOf(name: java.lang.String) : Weekday {
}
}
@@ -85,7 +85,7 @@ interface RenderLogTestBase {
fun UFile.checkContainingFileForAllElements() {
accept(object : UastVisitor {
override fun visitElement(node: UElement): Boolean {
if (node is PsiElement) {
if (node is PsiElement && node.isPhysical) {
val uElement = node.sourcePsi.toUElement()!!
Assert.assertEquals("getContainingUFile should be equal to source for ${uElement.javaClass}",
this@checkContainingFileForAllElements,
@@ -15,7 +15,7 @@ abstract class AbstractJavaRenderLogTest : AbstractJavaUastTest(), RenderLogTest
file.accept(object : UastVisitor {
override fun visitElement(node: UElement): Boolean {
if (node is PsiElement) {
if (node is PsiElement && node.isPhysical) {
UsefulTestCase.assertInstanceOf(node.containingFile, PsiJavaFile::class.java)
}
return false