@Nullable private CompileTimeConstant<?> getCompileTimeConstFromReferenceExpression( PsiReferenceExpression value, PostponedTasks taskList) { PsiElement resolveElement = value.resolve(); if (resolveElement instanceof PsiEnumConstant) { PsiElement psiElement = resolveElement.getParent(); if (psiElement instanceof PsiClass) { PsiClass psiClass = (PsiClass) psiElement; String fqName = psiClass.getQualifiedName(); if (fqName == null) { return null; } JetScope scope; ClassDescriptor classDescriptor = classResolver.resolveClass( new FqName(fqName), DescriptorSearchRule.INCLUDE_KOTLIN, taskList); if (classDescriptor == null) { return null; } ClassDescriptor classObjectDescriptor = classDescriptor.getClassObjectDescriptor(); if (classObjectDescriptor == null) { return null; } scope = classObjectDescriptor.getMemberScope(Lists.<TypeProjection>newArrayList()); Name identifier = Name.identifier(((PsiEnumConstant) resolveElement).getName()); Collection<VariableDescriptor> properties = scope.getProperties(identifier); for (VariableDescriptor variableDescriptor : properties) { if (variableDescriptor.getReceiverParameter() == null) { return new EnumValue((PropertyDescriptor) variableDescriptor); } } return null; } } return null; }
@NotNull private LookupResult lookupSimpleNameReference( @NotNull JetSimpleNameExpression referenceExpression, @NotNull JetScope outerScope, @NotNull LookupMode lookupMode, boolean namespaceLevel) { Name referencedName = referenceExpression.getReferencedNameAsName(); Set<DeclarationDescriptor> descriptors = Sets.newHashSet(); NamespaceDescriptor namespaceDescriptor = outerScope.getNamespace(referencedName); if (namespaceDescriptor != null) { descriptors.add(namespaceDescriptor); } ClassifierDescriptor classifierDescriptor = outerScope.getClassifier(referencedName); if (classifierDescriptor != null) { descriptors.add(classifierDescriptor); } if (lookupMode == LookupMode.ONLY_CLASSES) { ClassDescriptor objectDescriptor = outerScope.getObjectDescriptor(referencedName); if (objectDescriptor != null) { descriptors.add(objectDescriptor); } } else { descriptors.addAll(outerScope.getFunctions(referencedName)); descriptors.addAll(outerScope.getProperties(referencedName)); VariableDescriptor localVariable = outerScope.getLocalVariable(referencedName); if (localVariable != null) { descriptors.add(localVariable); } } return new SuccessfulLookupResult(descriptors, outerScope, namespaceLevel); }