1) Changed indentation of (single or double) quoted strings to align on the first...
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / ast / PrefixExpression.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.ASTVisitor;
14 import net.sourceforge.phpdt.internal.compiler.lookup.BlockScope;
15
16 public class PrefixExpression extends CompoundAssignment {
17
18         /**
19          * PrefixExpression constructor comment.
20          * 
21          * @param l
22          *            net.sourceforge.phpdt.internal.compiler.ast.Expression
23          * @param r
24          *            net.sourceforge.phpdt.internal.compiler.ast.Expression
25          * @param op
26          *            int
27          */
28         public PrefixExpression(Expression l, Expression e, int op, int pos) {
29
30                 super(l, e, op, l.sourceEnd);
31                 this.sourceStart = pos;
32                 this.sourceEnd = l.sourceEnd;
33         }
34
35         public String operatorToString() {
36
37                 switch (operator) {
38                 case PLUS:
39                         return "++"; //$NON-NLS-1$
40                 case MINUS:
41                         return "--"; //$NON-NLS-1$
42                 }
43                 return "unknown operator"; //$NON-NLS-1$
44         }
45
46         public boolean restrainUsageToNumericTypes() {
47
48                 return true;
49         }
50
51         public String toStringExpressionNoParenthesis() {
52
53                 return operatorToString() + " " + lhs.toStringExpression(); //$NON-NLS-1$
54
55         }
56
57         public void traverse(ASTVisitor visitor, BlockScope scope) {
58
59                 if (visitor.visit(this, scope)) {
60                         lhs.traverse(visitor, scope);
61                 }
62                 visitor.endVisit(this, scope);
63         }
64 }