X-Git-Url: http://git.phpeclipse.com diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/batch/CompilationUnit.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/batch/CompilationUnit.java index c944911..98c9cce 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/batch/CompilationUnit.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/batch/CompilationUnit.java @@ -17,70 +17,71 @@ import net.sourceforge.phpdt.internal.compiler.util.Util; import org.eclipse.core.resources.IResource; public class CompilationUnit implements ICompilationUnit { - public char[] contents; - - public char[] fileName; - - public char[] mainTypeName; - - String encoding; - - public CompilationUnit(char[] contents, String fileName, String encoding) { - this.contents = contents; - if (File.separator.equals("/")) { //$NON-NLS-1$ - if (fileName.indexOf("\\") != -1) { //$NON-NLS-1$ - fileName = fileName.replace('\\', File.separatorChar); - } - } else { - // the file separator is \ - if (fileName.indexOf('/') != -1) { - fileName = fileName.replace('/', File.separatorChar); - } - } - this.fileName = fileName.toCharArray(); - - int start = fileName.lastIndexOf("/") + 1; //$NON-NLS-1$ - if (start == 0 || start < fileName.lastIndexOf("\\")) //$NON-NLS-1$ - start = fileName.lastIndexOf("\\") + 1; //$NON-NLS-1$ - - int end = fileName.lastIndexOf("."); //$NON-NLS-1$ - if (end == -1) - end = fileName.length(); - - this.mainTypeName = fileName.substring(start, end).toCharArray(); - this.encoding = encoding; - } - - public char[] getContents() { - if (this.contents != null) - return this.contents; // answer the cached source - - // otherwise retrieve it - try { - return Util.getFileCharContent(new File(new String(this.fileName)), this.encoding); - } catch (IOException e) { - // assume no content then - } - return CharOperation.NO_CHAR; - } - - public char[] getFileName() { - return this.fileName; - } - - public char[] getMainTypeName() { - return this.mainTypeName; - } - - public char[][] getPackageName() { - return null; - } - - public String toString() { - return "CompilationUnit[" + new String(this.fileName) + "]"; //$NON-NLS-2$ //$NON-NLS-1$ - } - - public IResource getResource() { - return null; - } + public char[] contents; + + public char[] fileName; + + public char[] mainTypeName; + + String encoding; + + public CompilationUnit(char[] contents, String fileName, String encoding) { + this.contents = contents; + if (File.separator.equals("/")) { //$NON-NLS-1$ + if (fileName.indexOf("\\") != -1) { //$NON-NLS-1$ + fileName = fileName.replace('\\', File.separatorChar); + } + } else { + // the file separator is \ + if (fileName.indexOf('/') != -1) { + fileName = fileName.replace('/', File.separatorChar); + } + } + this.fileName = fileName.toCharArray(); + + int start = fileName.lastIndexOf("/") + 1; //$NON-NLS-1$ + if (start == 0 || start < fileName.lastIndexOf("\\")) //$NON-NLS-1$ + start = fileName.lastIndexOf("\\") + 1; //$NON-NLS-1$ + + int end = fileName.lastIndexOf("."); //$NON-NLS-1$ + if (end == -1) + end = fileName.length(); + + this.mainTypeName = fileName.substring(start, end).toCharArray(); + this.encoding = encoding; + } + + public char[] getContents() { + if (this.contents != null) + return this.contents; // answer the cached source + + // otherwise retrieve it + try { + return Util.getFileCharContent(new File(new String(this.fileName)), + this.encoding); + } catch (IOException e) { + // assume no content then + } + return CharOperation.NO_CHAR; + } + + public char[] getFileName() { + return this.fileName; + } + + public char[] getMainTypeName() { + return this.mainTypeName; + } + + public char[][] getPackageName() { + return null; + } + + public String toString() { + return "CompilationUnit[" + new String(this.fileName) + "]"; //$NON-NLS-2$ //$NON-NLS-1$ + } + + public IResource getResource() { + return null; + } } \ No newline at end of file