1 16 package com.google.gwt.dev.jdt; 17 18 import com.google.gwt.core.ext.UnableToCompleteException; 19 import com.google.gwt.core.ext.typeinfo.CompilationUnitProvider; 20 21 import org.eclipse.jdt.core.compiler.CharOperation; 22 import org.eclipse.jdt.internal.compiler.env.ICompilationUnit; 23 24 28 public class ICompilationUnitAdapter implements ICompilationUnit { 29 30 private final CompilationUnitProvider cup; 31 32 public ICompilationUnitAdapter(CompilationUnitProvider cup) { 33 assert (cup != null); 34 this.cup = cup; 35 } 36 37 public CompilationUnitProvider getCompilationUnitProvider() { 38 return cup; 39 } 40 41 public char[] getContents() { 42 try { 43 return cup.getSource(); 44 } catch (UnableToCompleteException e) { 45 return null; 46 } 47 } 48 49 public char[] getFileName() { 50 return cup.getLocation().toCharArray(); 51 } 52 53 public char[] getMainTypeName() { 54 return null; 56 } 57 58 public char[][] getPackageName() { 59 final char[] pkg = cup.getPackageName().toCharArray(); 60 final char[][] pkgParts = CharOperation.splitOn('.', pkg); 61 return pkgParts; 62 } 63 } 64 | Popular Tags |