added -J option to preserve unmodified files in preexisting jarfile
[org.ibex.tool.git] / src / org / eclipse / jdt / internal / compiler / ast / AbstractVariableDeclaration.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2004 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials 
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  * 
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  *******************************************************************************/
11 package org.eclipse.jdt.internal.compiler.ast;
12
13 import org.eclipse.jdt.internal.compiler.flow.FlowContext;
14 import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
15 import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
16 import org.eclipse.jdt.internal.compiler.lookup.InvocationSite;
17 import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
18 import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
19
20 public abstract class AbstractVariableDeclaration extends Statement implements InvocationSite {
21         public int declarationEnd;
22         public int declarationSourceEnd;
23         public int declarationSourceStart;
24         public int hiddenVariableDepth; // used to diagnose hiding scenarii
25         public Expression initialization;
26         public int modifiers;
27         public int modifiersSourceStart;
28         public Annotation[] annotations;
29
30         public char[] name;
31
32         public TypeReference type;
33         
34         public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo) {
35                 return flowInfo;
36         }
37         
38         public static final int FIELD = 1;
39         public static final int INITIALIZER = 2;
40         public static final int ENUM_CONSTANT = 3;
41         public static final int LOCAL_VARIABLE = 4;
42         public static final int PARAMETER = 5;
43         public static final int TYPE_PARAMETER = 6;
44         
45         
46         /**
47          * @see org.eclipse.jdt.internal.compiler.lookup.InvocationSite#genericTypeArguments()
48          */
49         public TypeBinding[] genericTypeArguments() {
50                 return null;
51         }
52         
53         /**
54          * Returns the constant kind of this variable declaration
55          */
56         public abstract int getKind();
57         
58         /* (non-Javadoc)
59          * @see org.eclipse.jdt.internal.compiler.lookup.InvocationSite#isSuperAccess()
60          */
61         public boolean isSuperAccess() {
62                 return false;
63         }
64
65         /* (non-Javadoc)
66          * @see org.eclipse.jdt.internal.compiler.lookup.InvocationSite#isTypeAccess()
67          */
68         public boolean isTypeAccess() {
69                 return false;
70         }
71
72         public StringBuffer printStatement(int indent, StringBuffer output) {
73
74                 printIndent(indent, output);
75                 printModifiers(this.modifiers, output);
76                 if (this.annotations != null) printAnnotations(this.annotations, output);
77                 
78                 if (type != null) {
79                         type.print(0, output).append(' ');
80                 }
81                 output.append(this.name); 
82                 switch(getKind()) {
83                         case ENUM_CONSTANT:
84                                 if (initialization != null) {
85                                         initialization.printExpression(indent, output);
86                                 }
87                                 return output.append(',');
88                         default:
89                                 if (initialization != null) {
90                                         output.append(" = "); //$NON-NLS-1$
91                                         initialization.printExpression(indent, output);
92                                 }
93                                 return output.append(';');
94                 }
95         }
96
97         public void resolve(BlockScope scope) {
98                 // do nothing by default (redefined for local variables)
99         }
100
101         /* (non-Javadoc)
102          * @see org.eclipse.jdt.internal.compiler.lookup.InvocationSite#setActualReceiverType(org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding)
103          */
104         public void setActualReceiverType(ReferenceBinding receiverType) {
105                 // do nothing by default
106         }
107
108         /* (non-Javadoc)
109          * @see org.eclipse.jdt.internal.compiler.lookup.InvocationSite#setDepth(int)
110          */
111         public void setDepth(int depth) {
112
113                 this.hiddenVariableDepth = depth;
114         }
115
116         /* (non-Javadoc)
117          * @see org.eclipse.jdt.internal.compiler.lookup.InvocationSite#setFieldIndex(int)
118          */
119         public void setFieldIndex(int depth) {
120                 // do nothing by default
121         }
122 }