@NotNull @Override public LightClassConstructionContext getContextForClassOrObject( @NotNull JetClassOrObject classOrObject) { ResolveSessionForBodies session = KotlinCacheService.getInstance(classOrObject.getProject()) .getLazyResolveSession(classOrObject); if (classOrObject.isLocal()) { BindingContext bindingContext = session.resolveToElement(classOrObject, BodyResolveMode.FULL); ClassDescriptor descriptor = bindingContext.get(BindingContext.CLASS, classOrObject); if (descriptor == null) { LOG.warn( "No class descriptor in context for class: " + PsiUtilPackage.getElementTextWithContext(classOrObject)); return new LightClassConstructionContext(bindingContext, session.getModuleDescriptor()); } ForceResolveUtil.forceResolveAllContents(descriptor); return new LightClassConstructionContext(bindingContext, session.getModuleDescriptor()); } ForceResolveUtil.forceResolveAllContents(session.getClassDescriptor(classOrObject)); return new LightClassConstructionContext( session.getBindingContext(), session.getModuleDescriptor()); }
@NotNull @Override public LightClassConstructionContext getContextForPackage(@NotNull Collection<JetFile> files) { assert !files.isEmpty() : "No files in package"; List<JetFile> sortedFiles = new ArrayList<JetFile>(files); Collections.sort(sortedFiles, scopeFileComparator); JetFile file = sortedFiles.get(0); ResolveSessionForBodies session = KotlinCacheService.getInstance(file.getProject()).getLazyResolveSession(file); forceResolvePackageDeclarations(files, session); return new LightClassConstructionContext( session.getBindingContext(), session.getModuleDescriptor()); }