first scanner /parser copied from the jdt java version
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / ast / SuperReference.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
3  * All rights reserved. This program and the accompanying materials 
4  * are made available under the terms of the Common Public License v0.5 
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v05.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.IAbstractSyntaxTreeVisitor;
14 import net.sourceforge.phpdt.internal.compiler.lookup.BlockScope;
15 import net.sourceforge.phpdt.internal.compiler.lookup.SourceTypeBinding;
16 import net.sourceforge.phpdt.internal.compiler.lookup.TypeBinding;
17
18 public class SuperReference extends ThisReference {
19         public static final SuperReference Super = new SuperReference();
20         
21 /**
22  * SuperReference constructor comment.
23  */
24 public SuperReference() {
25         super();
26 }
27 public SuperReference(int pos, int sourceEnd) {
28         super();
29         sourceStart = pos;
30         this.sourceEnd = sourceEnd;
31 }
32 public static ExplicitConstructorCall implicitSuperConstructorCall() {
33         return new ExplicitConstructorCall(ExplicitConstructorCall.ImplicitSuper);
34 }
35 public boolean isSuper() {
36         
37         return true;
38 }
39 public boolean isThis() {
40         
41         return false ;
42 }
43 public TypeBinding resolveType(BlockScope scope) {
44         constant = NotAConstant;
45         if (!checkAccess(scope.methodScope()))
46                 return null;
47         SourceTypeBinding enclosingTb = scope.enclosingSourceType();
48         if (scope.isJavaLangObject(enclosingTb)) {
49                 scope.problemReporter().cannotUseSuperInJavaLangObject(this);
50                 return null;
51         }
52         return enclosingTb.superclass;
53 }
54 public String toStringExpression(){
55
56         return "super"; //$NON-NLS-1$
57         
58 }
59 public void traverse(IAbstractSyntaxTreeVisitor visitor, BlockScope blockScope) {
60         visitor.visit(this, blockScope);
61         visitor.endVisit(this, blockScope);
62 }
63 }