Rename HTML editor to Smarty editor
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / ast / AbstractVariableDeclaration.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2003 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 net.sourceforge.phpdt.internal.compiler.ast;
12
13 import net.sourceforge.phpdt.internal.compiler.flow.FlowContext;
14 import net.sourceforge.phpdt.internal.compiler.flow.FlowInfo;
15 import net.sourceforge.phpdt.internal.compiler.lookup.BlockScope;
16
17 public abstract class AbstractVariableDeclaration extends Statement {
18         public int modifiers;
19
20         public TypeReference type;
21         public Expression initialization;
22
23         public char[] name;
24         public int declarationEnd;
25         public int declarationSourceStart;
26         public int declarationSourceEnd;
27         public int modifiersSourceStart;
28         
29         public AbstractVariableDeclaration() {}
30
31         public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo) {
32                 return flowInfo;
33         }
34
35         public abstract String name();
36         public StringBuffer printStatement(int indent, StringBuffer output) {
37
38                 printIndent(indent, output);
39                 printModifiers(this.modifiers, output);
40                 type.print(0, output).append(' ').append(this.name); 
41                 if (initialization != null) {
42                         output.append(" = "); //$NON-NLS-1$
43                         initialization.printExpression(indent, output);
44                 }
45                 return output.append(';');
46         }
47
48         public void resolve(BlockScope scope) {}
49                 
50         public String toString(int tab) {
51
52                 String s = tabString(tab);
53                 if (modifiers != AccDefault) {
54                         s += modifiersString(modifiers);
55                 }
56                 s += type.toString(0) + " " + new String(name()); //$NON-NLS-1$
57                 if (initialization != null)
58                         s += " = " + initialization.toStringExpression(tab); //$NON-NLS-1$
59                 return s;
60         }
61 }