@SuppressWarnings("ConstantConditions") private JetScope addImports(JetScope scope) { WritableScopeImpl writableScope = new WritableScopeImpl( scope, scope.getContainingDeclaration(), RedeclarationHandler.DO_NOTHING, "JetTypeCheckerTest.addImports"); List<JetScope> scopeChain = new ArrayList<JetScope>(); scopeChain.add(writableScope); ModuleDescriptor module = LazyResolveTestUtil.resolveProject(getProject()); for (ImportPath defaultImport : module.getDefaultImports()) { FqName fqName = defaultImport.fqnPart(); if (defaultImport.isAllUnder()) { scopeChain.add(module.getPackage(fqName).getMemberScope()); } else { Name shortName = fqName.shortName(); assert shortName.equals(defaultImport.getImportedName()); writableScope.addClassifierDescriptor( module.getPackage(fqName.parent()).getMemberScope().getClassifier(shortName)); } } scopeChain.add(module.getPackage(FqName.ROOT).getMemberScope()); writableScope.changeLockLevel(WritableScope.LockLevel.BOTH); return new ChainedScope( scope.getContainingDeclaration(), "JetTypeCheckerTest.addImports scope with imports", scopeChain.toArray(new JetScope[scopeChain.size()])); }
@NotNull public JetScope getScopeForClassHeaderResolution() { if (scopeForClassHeaderResolution == null) { WritableScopeImpl scope = new WritableScopeImpl( JetScope.EMPTY, this, RedeclarationHandler.DO_NOTHING, "Class Header Resolution"); for (TypeParameterDescriptor typeParameterDescriptor : getTypeConstructor().getParameters()) { scope.addClassifierDescriptor(typeParameterDescriptor); } scope.changeLockLevel(WritableScope.LockLevel.READING); scopeForClassHeaderResolution = new ChainedScope( this, scope, resolveSession.getResolutionScope( declarationProvider.getOwnerInfo().getScopeAnchor())); } return scopeForClassHeaderResolution; }
@NotNull private JetScope computeScopeForClassHeaderResolution() { WritableScopeImpl scope = new WritableScopeImpl( JetScope.EMPTY, this, RedeclarationHandler.DO_NOTHING, "Scope with type parameters for " + getName()); for (TypeParameterDescriptor typeParameterDescriptor : getTypeConstructor().getParameters()) { scope.addClassifierDescriptor(typeParameterDescriptor); } scope.changeLockLevel(WritableScope.LockLevel.READING); PsiElement scopeAnchor = declarationProvider.getOwnerInfo().getScopeAnchor(); return new ChainedScope( this, "ScopeForClassHeaderResolution: " + getName(), scope, getScopeProvider().getResolutionScopeForDeclaration(scopeAnchor)); }