KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > google > gwt > dev > jdt > SourceOracleOnTypeOracle


1 /*
2  * Copyright 2006 Google Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5  * use this file except in compliance with the License. You may obtain a copy of
6  * 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, WITHOUT
12  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13  * License for the specific language governing permissions and limitations under
14  * the License.
15  */

16 package com.google.gwt.dev.jdt;
17
18 import com.google.gwt.core.ext.TreeLogger;
19 import com.google.gwt.core.ext.typeinfo.CompilationUnitProvider;
20 import com.google.gwt.core.ext.typeinfo.JClassType;
21 import com.google.gwt.core.ext.typeinfo.TypeOracle;
22
23 /**
24  * Implements a {@link SourceOracle} in terms of a {@link TypeOracle}.
25  */

26 public class SourceOracleOnTypeOracle implements SourceOracle {
27
28   private final TypeOracle typeOracle;
29
30   public SourceOracleOnTypeOracle(TypeOracle typeOracle) {
31     this.typeOracle = typeOracle;
32   }
33
34   public CompilationUnitProvider findCompilationUnit(TreeLogger logger,
35       String JavaDoc sourceTypeName) {
36     JClassType type = typeOracle.findType(sourceTypeName);
37     if (type != null) {
38       return type.getCompilationUnit();
39     }
40     return null;
41   }
42
43   public boolean isPackage(String JavaDoc possiblePackageName) {
44     if (typeOracle.findPackage(possiblePackageName) != null) {
45       return true;
46     } else {
47       return false;
48     }
49   }
50 }
51
Popular Tags