Skip to main content
summaryrefslogtreecommitdiffstats
blob: 192d62644ecd5a37c5e7f6b775044e4a4effbb8a (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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package org.eclipse.jdt.internal.core.builder.impl;

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

import java.util.*;

/**
 * 
 */
public class JCUNode extends AbstractNode {
	/* The compilation unit */
	PackageElement fUnit;

	/* The types that belong to the compilation unit */
	IType[] fTypes;

	/* empty types list */
	protected static final IType[] fgNoTypes = new IType[0];
	public JCUNode (PackageElement unit) {
		fUnit = unit;
		fTypes = fgNoTypes;
	}
	public JCUNode (PackageElement unit, IType[] types) {
		fUnit = unit;

		/* never let types be null */
		fTypes = types == null ? fgNoTypes : types;
	}
	/**
	 * Returns a copy of this node, without copying dependencies.  Used
	 * by DependencyGraph.copy().
	 */
	public AbstractNode copy() {
		return new JCUNode(fUnit, fTypes);
	}
	/**
	 * Returns the element which this node represents.
	 */
	public Object getElement() {
		return fUnit;
	}
	/**
	 * Returns the number of bytes that this node uses.
	 * For debugging and profiling purposes only.
	 */
	int getFootprint() {
		int size = super.getFootprint();

		/* slot for package element */
		size += 4;

		/* slots for types */
		if (fTypes != null) {
			size += fTypes.length * 4;
		}
		return size;
	}
	/**
	 * Returns what kind of node this is.
	 */
	public int getKind() {
		return JCU_NODE;
	}
	public PackageElement getPackageElement() {
		return fUnit;
	}
	/**
	 * Returns the types that belong to this compilation unit
	 */
	public IType[] getTypes() {
		return fTypes;
	}
	/**
	 * Sets the types that belong to this compilation unit
	 */
	public void setTypes(IType[] types) {
		/* never let types be null */
		fTypes = types == null ? fgNoTypes : types;
	}
	/**
	 * Prints a string representation of the node.  This method is for debugging
	 * purposes only.
	 */
	public String toString() {
		return "JCUNode("/*nonNLS*/ + fUnit.getFileName() + ")"/*nonNLS*/;
	}
}

Back to the top