コード例 #1
0
 @Nullable
 public static JetTypeInfo getRecordedTypeInfo(
     @NotNull JetExpression expression, @NotNull BindingContext context) {
   if (!context.get(BindingContext.PROCESSED, expression)) return null;
   DataFlowInfo dataFlowInfo = BindingContextUtilPackage.getDataFlowInfo(context, expression);
   JetType type = context.get(BindingContext.EXPRESSION_TYPE, expression);
   return JetTypeInfo.create(type, dataFlowInfo);
 }
コード例 #2
0
 @Nullable
 public static JetTypeInfo getRecordedTypeInfo(
     @NotNull JetExpression expression, @NotNull BindingContext context) {
   // noinspection ConstantConditions
   if (!context.get(BindingContext.PROCESSED, expression)) return null;
   // NB: should never return null if expression is already processed
   JetTypeInfo result = context.get(BindingContext.EXPRESSION_TYPE_INFO, expression);
   return result != null ? result : TypeInfoFactoryPackage.noTypeInfo(DataFlowInfo.EMPTY);
 }
コード例 #3
0
 public static boolean isVarCapturedInClosure(
     BindingContext bindingContext, DeclarationDescriptor descriptor) {
   if (!(descriptor instanceof VariableDescriptor) || descriptor instanceof PropertyDescriptor)
     return false;
   VariableDescriptor variableDescriptor = (VariableDescriptor) descriptor;
   return bindingContext.get(CAPTURED_IN_CLOSURE, variableDescriptor) != null
       && variableDescriptor.isVar();
 }
コード例 #4
0
 @NotNull
 public static <K, V> V getNotNull(
     @NotNull BindingContext bindingContext,
     @NotNull ReadOnlySlice<K, V> slice,
     @NotNull K key,
     @NotNull String messageIfNull) {
   V value = bindingContext.get(slice, key);
   if (value == null) {
     throw new IllegalStateException(messageIfNull);
   }
   return value;
 }
コード例 #5
0
 @Nullable
 public static VariableDescriptor extractVariableDescriptorIfAny(
     @NotNull BindingContext bindingContext, @Nullable JetElement element, boolean onlyReference) {
   DeclarationDescriptor descriptor = null;
   if (!onlyReference
       && (element instanceof JetVariableDeclaration || element instanceof JetParameter)) {
     descriptor = bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, element);
   } else if (element instanceof JetSimpleNameExpression) {
     descriptor =
         bindingContext.get(BindingContext.REFERENCE_TARGET, (JetSimpleNameExpression) element);
   } else if (element instanceof JetQualifiedExpression) {
     descriptor =
         extractVariableDescriptorIfAny(
             bindingContext,
             ((JetQualifiedExpression) element).getSelectorExpression(),
             onlyReference);
   }
   if (descriptor instanceof VariableDescriptor) {
     return (VariableDescriptor) descriptor;
   }
   return null;
 }
コード例 #6
0
 @NotNull
 public static DeclarationDescriptor getEnclosingDescriptor(
     @NotNull BindingContext context, @NotNull JetElement element) {
   JetNamedDeclaration declaration =
       PsiTreeUtil.getParentOfType(element, JetNamedDeclaration.class);
   if (declaration instanceof JetFunctionLiteral) {
     return getEnclosingDescriptor(context, declaration);
   }
   DeclarationDescriptor descriptor = context.get(DECLARATION_TO_DESCRIPTOR, declaration);
   assert descriptor != null
       : "No descriptor for named declaration: "
           + declaration.getText()
           + "\n(of type "
           + declaration.getClass()
           + ")";
   return descriptor;
 }
コード例 #7
0
 public static FunctionDescriptor getEnclosingFunctionDescriptor(
     @NotNull BindingContext context, @NotNull JetElement element) {
   JetFunction function = PsiTreeUtil.getParentOfType(element, JetFunction.class);
   return (FunctionDescriptor) context.get(DECLARATION_TO_DESCRIPTOR, function);
 }
コード例 #8
0
 @Nullable
 public static ResolvedCall<ConstructorDescriptor> getDelegationConstructorCall(
     @NotNull BindingContext bindingContext,
     @NotNull ConstructorDescriptor constructorDescriptor) {
   return bindingContext.get(CONSTRUCTOR_RESOLVED_DELEGATION_CALL, constructorDescriptor);
 }