01: /*
02: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
03: *
04: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
05: *
06: * The contents of this file are subject to the terms of either the GNU
07: * General Public License Version 2 only ("GPL") or the Common
08: * Development and Distribution License("CDDL") (collectively, the
09: * "License"). You may not use this file except in compliance with the
10: * License. You can obtain a copy of the License at
11: * http://www.netbeans.org/cddl-gplv2.html
12: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13: * specific language governing permissions and limitations under the
14: * License. When distributing the software, include this License Header
15: * Notice in each file and include the License file at
16: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
17: * particular file as subject to the "Classpath" exception as provided
18: * by Sun in the GPL Version 2 section of the License file that
19: * accompanied this code. If applicable, add the following below the
20: * License Header, with the fields enclosed by brackets [] replaced by
21: * your own identifying information:
22: * "Portions Copyrighted [year] [name of copyright owner]"
23: *
24: * Contributor(s):
25: *
26: * Portions Copyrighted 2007 Sun Microsystems, Inc.
27: */
28: package org.netbeans.modules.java.source.transform;
29:
30: import com.sun.source.tree.Tree;
31: import com.sun.source.tree.TreeVisitor;
32: import com.sun.tools.javac.tree.JCTree;
33: import com.sun.tools.javac.tree.JCTree.JCVariableDecl;
34: import com.sun.tools.javac.tree.JCTree.Visitor;
35: import com.sun.tools.javac.tree.TreeInfo;
36: import java.util.List;
37:
38: /**
39: * Fake tree. Represents fields separated by comma.
40: *
41: * @author pflaska
42: */
43: public class FieldGroupTree extends JCTree implements Tree {
44:
45: private List<JCVariableDecl> vars;
46: private boolean enumeration;
47:
48: public FieldGroupTree(List<JCVariableDecl> vars, boolean enumeration) {
49: this .vars = vars;
50: pos = TreeInfo.getStartPos(vars.get(0));
51: this .enumeration = enumeration;
52: }
53:
54: public Kind getKind() {
55: return Kind.OTHER;
56: }
57:
58: public List<JCVariableDecl> getVariables() {
59: return vars;
60: }
61:
62: public boolean isEnum() {
63: return enumeration;
64: }
65:
66: public int endPos() {
67: return TreeInfo.endPos(vars.get(vars.size() - 1));
68: }
69:
70: public <R, D> R accept(TreeVisitor<R, D> arg0, D arg1) {
71: throw new UnsupportedOperationException("Not supported yet.");
72: }
73:
74: public void accept(Visitor arg0) {
75: throw new UnsupportedOperationException("Not supported yet.");
76: }
77:
78: @Override
79: public boolean equals(Object arg0) {
80: if (arg0 instanceof FieldGroupTree) {
81: return vars.equals(((FieldGroupTree) arg0).getVariables());
82: }
83: return false;
84: }
85:
86: @Override
87: public int hashCode() {
88: return vars.hashCode();
89: }
90:
91: public int getTag() {
92: return 0;
93: }
94: }
|