1 11 package org.eclipse.jdt.internal.core.util; 12 13 import java.net.URI ; 14 15 import org.eclipse.core.resources.IFile; 16 import org.eclipse.core.runtime.CoreException; 17 import org.eclipse.jdt.core.compiler.CharOperation; 18 import org.eclipse.jdt.internal.compiler.batch.CompilationUnit; 19 20 23 public class ResourceCompilationUnit extends CompilationUnit { 24 25 private IFile file; 26 27 public ResourceCompilationUnit(IFile file, URI location) { 28 super(null, location == null ? file.getFullPath().toString() : location.getPath(), null); 29 this.file = file; 30 } 31 32 public char[] getContents() { 33 if (this.contents != null) 34 return this.contents; 36 try { 38 return Util.getResourceContentsAsCharArray(this.file); 39 } catch (CoreException e) { 40 return CharOperation.NO_CHAR; 41 } 42 } 43 } 44 | Popular Tags |