01: package javaparser;
02:
03: import java.util.*;
04: import javaparser.javacc_gen.Token;
05: import tide.editor.UIConstants;
06:
07: public class PackageNode extends MainNode {
08: public String packageName = "";
09:
10: /** For the unnamed scope, when no explicit declaration was made.
11: */
12: public PackageNode() {
13: super ("package", null, null, false);
14: }
15:
16: public PackageNode(ParserTreeNode packageDeclarationNode) {
17: super ("", "package", UIConstants.blue, false);
18:
19: ArrayList<Token> tokens = new ArrayList<Token>();
20: Utils.collectChilds(packageDeclarationNode, tokens);
21: //ci.simplifiedDescription = "package "+createImportText(tokens);
22: this .packageName = "";
23: for (int i = 1; i < tokens.size() - 1; i++) // ignore ";" and "package"
24: {
25: packageName += tokens.get(i);
26: }
27:
28: this .setStartPosFrom(tokens.get(0));
29: this .setEndPosFrom(tokens.get(tokens.size() - 1));
30:
31: }
32:
33: public PackageNode(RAWParserTreeNode packageDeclarationNode) {
34: super ("", "package", UIConstants.blue, false);
35:
36: ArrayList<Token> tokens = new ArrayList<Token>();
37: CCTreeUtils.collectChilds(packageDeclarationNode, tokens);
38: //ci.simplifiedDescription = "package "+createImportText(tokens);
39: this .packageName = "";
40: for (int i = 1; i < tokens.size() - 1; i++) // ignore ";" and "package"
41: {
42: packageName += tokens.get(i);
43: }
44:
45: this .setStartPosFrom(tokens.get(0));
46: this .setEndPosFrom(tokens.get(tokens.size() - 1));
47:
48: }
49:
50: @Override
51: public String toString() {
52: return packageName;
53: }
54:
55: /** call this to help GC !
56: */
57: @Override
58: public void terminate() {
59: packageName = null;
60: }
61:
62: }
|