X-Git-Url: http://git.phpeclipse.com
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/BasicCompilationUnit.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/BasicCompilationUnit.java
index cbc4cbb..f0176e0 100644
--- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/BasicCompilationUnit.java
+++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/BasicCompilationUnit.java
@@ -1,70 +1,75 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package net.sourceforge.phpdt.internal.core;
import java.io.File;
import java.io.IOException;
+import net.sourceforge.phpdt.core.compiler.CharOperation;
import net.sourceforge.phpdt.internal.compiler.env.ICompilationUnit;
import net.sourceforge.phpdt.internal.compiler.util.Util;
+import org.eclipse.core.resources.IResource;
+
/**
* A basic implementation of ICompilationUnit
* for use in the SourceMapper
.
* @see ICompilationUnit
*/
public class BasicCompilationUnit implements ICompilationUnit {
- protected char[] contents;
- protected char[] fileName;
- protected char[][] packageName;
- protected char[] mainTypeName;
- protected String encoding;
-
-public BasicCompilationUnit(char[] contents, char[][] packageName, String fileName, String encoding) {
- this.contents = contents;
- this.fileName = fileName.toCharArray();
- this.packageName = packageName;
+ protected char[] contents;
+ protected char[] fileName;
+ protected char[][] packageName;
+ protected char[] mainTypeName;
+ protected String encoding;
- int start = fileName.lastIndexOf("/") + 1; //$NON-NLS-1$
- if (start == 0 || start < fileName.lastIndexOf("\\")) //$NON-NLS-1$
- start = fileName.lastIndexOf("\\") + 1; //$NON-NLS-1$
+ public BasicCompilationUnit(char[] contents, char[][] packageName, String fileName, String encoding) {
+ this.contents = contents;
+ this.fileName = fileName.toCharArray();
+ this.packageName = packageName;
- int end = fileName.lastIndexOf("."); //$NON-NLS-1$
- if (end == -1)
- end = fileName.length();
+ int start = fileName.lastIndexOf("/") + 1; //$NON-NLS-1$
+ if (start == 0 || start < fileName.lastIndexOf("\\")) //$NON-NLS-1$
+ start = fileName.lastIndexOf("\\") + 1; //$NON-NLS-1$
- this.mainTypeName = fileName.substring(start, end).toCharArray();
- this.encoding = encoding;
-}
-public char[] getContents() {
- if (this.contents != null)
- return this.contents; // answer the cached source
+ 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(fileName)), this.encoding);
+ } catch (IOException e) {
+ }
+ return CharOperation.NO_CHAR;
+ }
+ public char[] getFileName() {
+ return this.fileName;
+ }
+ public char[] getMainTypeName() {
+ return this.mainTypeName;
+ }
+ public char[][] getPackageName() {
+ return this.packageName;
+ }
+ public String toString() {
+ return "CompilationUnit: " + new String(fileName); //$NON-NLS-1$
+ }
+
- // otherwise retrieve it
- try {
- return Util.getFileCharContent(new File(new String(fileName)), this.encoding);
- } catch (IOException e) {
- }
- return new char[0];
-}
-public char[] getFileName() {
- return this.fileName;
-}
-public char[] getMainTypeName() {
- return this.mainTypeName;
-}
-public char[][] getPackageName() {
- return this.packageName;
-}
-public String toString(){
- return "CompilationUnit: "+new String(fileName); //$NON-NLS-1$
-}
}