Skip to main content
summaryrefslogtreecommitdiffstats
blob: 4583cd92e2baab1a8bca03047c70d897aeee5ece (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package org.eclipse.jdt.internal.core.jdom;

/*
 * (c) Copyright IBM Corp. 2000, 2001.
 * All Rights Reserved.
 */
import org.eclipse.jdt.internal.compiler.env.*;

import java.io.*;

/**
 * Implements a very simple version of the ICompilationUnit
 *
 * <p>Please do not use outside of jdom.
 */
public class CompilationUnit implements ICompilationUnit {
	protected char[] fContents;
	protected char[] fFileName;
	protected char[] fMainTypeName;
public CompilationUnit(char[] contents, char[] filename) {
	fContents = contents;
	fFileName = filename;

	String file = new String(filename);
	int start = file.lastIndexOf("/") + 1;
	if (start == 0 || start < file.lastIndexOf("\\"))
		start = file.lastIndexOf("\\") + 1;

	int end = file.lastIndexOf(".");
	if (end == -1)
		end = file.length();

	fMainTypeName = file.substring(start, end).toCharArray();
}
public char[] getContents() {
	return fContents;
}
public char[] getFileName() {
	return fFileName;
}
public char[] getMainTypeName() {
	return fMainTypeName;
}
public String toString() {
	return "CompilationUnit[" + new String(fFileName) + "]"; 
}
}

Back to the top