KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > compiler > ast > SuperReference


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-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.ASTVisitor;
14 import org.eclipse.jdt.internal.compiler.impl.Constant;
15 import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
16 import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
17 import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
18
19 public class SuperReference extends ThisReference {
20     
21     public SuperReference(int sourceStart, int sourceEnd) {
22
23         super(sourceStart, sourceEnd);
24     }
25
26     public static ExplicitConstructorCall implicitSuperConstructorCall() {
27
28         return new ExplicitConstructorCall(ExplicitConstructorCall.ImplicitSuper);
29     }
30
31     public boolean isImplicitThis() {
32         
33         return false;
34     }
35
36     public boolean isSuper() {
37         
38         return true;
39     }
40
41     public boolean isThis() {
42         
43         return false ;
44     }
45
46     public StringBuffer JavaDoc printExpression(int indent, StringBuffer JavaDoc output){
47     
48         return output.append("super"); //$NON-NLS-1$
49

50     }
51
52     public TypeBinding resolveType(BlockScope scope) {
53
54         constant = Constant.NotAConstant;
55         if (!checkAccess(scope.methodScope()))
56             return null;
57         ReferenceBinding enclosingReceiverType = scope.enclosingReceiverType();
58         if (enclosingReceiverType.id == T_JavaLangObject) {
59             scope.problemReporter().cannotUseSuperInJavaLangObject(this);
60             return null;
61         }
62         return this.resolvedType = enclosingReceiverType.superclass();
63     }
64
65     public void traverse(ASTVisitor visitor, BlockScope blockScope) {
66         visitor.visit(this, blockScope);
67         visitor.endVisit(this, blockScope);
68     }
69 }
70
Popular Tags