Home | History | Annotate | Download | only in bound
      1 /*
      2  * Copyright 2016 Google Inc. All Rights Reserved.
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *     http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package com.google.turbine.binder.bound;
     18 
     19 import com.google.common.collect.ImmutableMap;
     20 import com.google.turbine.binder.lookup.ImportScope;
     21 import com.google.turbine.binder.lookup.MemberImportIndex;
     22 import com.google.turbine.binder.sym.ClassSymbol;
     23 import com.google.turbine.diag.SourceFile;
     24 import com.google.turbine.model.TurbineTyKind;
     25 import com.google.turbine.tree.Tree;
     26 
     27 /** A {@link BoundClass} with shared lookup scopes for the current compilation unit and package. */
     28 public class PackageSourceBoundClass implements BoundClass {
     29   private final SourceBoundClass base;
     30   private final ImportScope scope;
     31   private final MemberImportIndex memberImports;
     32   private final SourceFile source;
     33 
     34   public PackageSourceBoundClass(
     35       SourceBoundClass base,
     36       ImportScope scope,
     37       MemberImportIndex memberImports,
     38       SourceFile source) {
     39     this.base = base;
     40     this.scope = scope;
     41     this.memberImports = memberImports;
     42     this.source = source;
     43   }
     44 
     45   public Tree.TyDecl decl() {
     46     return base.decl();
     47   }
     48 
     49   @Override
     50   public TurbineTyKind kind() {
     51     return base.kind();
     52   }
     53 
     54   @Override
     55   public ClassSymbol owner() {
     56     return base.owner();
     57   }
     58 
     59   @Override
     60   public int access() {
     61     return base.access();
     62   }
     63 
     64   @Override
     65   public ImmutableMap<String, ClassSymbol> children() {
     66     return base.children();
     67   }
     68 
     69   public ImportScope scope() {
     70     return scope;
     71   }
     72 
     73   /** The static member import index for the enclosing compilation unit. */
     74   public MemberImportIndex memberImports() {
     75     return memberImports;
     76   }
     77 
     78   /** The source file. */
     79   public SourceFile source() {
     80     return source;
     81   }
     82 }
     83