KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > codeassist > select > SelectionOnExplicitConstructorCall


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.codeassist.select;
12
13 /*
14  * Selection node build by the parser in any case it was intending to
15  * reduce an explicit constructor call containing the cursor.
16  * e.g.
17  *
18  * class X {
19  * void foo() {
20  * Y.[start]super[end](1, 2)
21  * }
22  * }
23  *
24  * ---> class X {
25  * void foo() {
26  * <SelectOnExplicitConstructorCall:Y.super(1, 2)>
27  * }
28  * }
29  *
30  */

31
32 import org.eclipse.jdt.internal.compiler.ast.*;
33 import org.eclipse.jdt.internal.compiler.lookup.*;
34
35 public class SelectionOnExplicitConstructorCall extends ExplicitConstructorCall {
36
37     public SelectionOnExplicitConstructorCall(int accessMode) {
38
39         super(accessMode);
40     }
41
42     public StringBuffer JavaDoc printStatement(int tab, StringBuffer JavaDoc output) {
43
44         printIndent(tab, output);
45         output.append("<SelectOnExplicitConstructorCall:"); //$NON-NLS-1$
46
if (qualification != null) qualification.printExpression(0, output).append('.');
47         if (accessMode == This) {
48             output.append("this("); //$NON-NLS-1$
49
} else {
50             output.append("super("); //$NON-NLS-1$
51
}
52         if (arguments != null) {
53             for (int i = 0; i < arguments.length; i++) {
54                 if (i > 0) output.append(", "); //$NON-NLS-1$
55
arguments[i].printExpression(0, output);
56             }
57         }
58         return output.append(")>;"); //$NON-NLS-1$
59
}
60
61     public void resolve(BlockScope scope) {
62
63         super.resolve(scope);
64     
65         // tolerate some error cases
66
if (binding == null ||
67                 !(binding.isValidBinding() ||
68                     binding.problemId() == ProblemReasons.NotVisible))
69             throw new SelectionNodeFound();
70         else
71             throw new SelectionNodeFound(binding);
72     }
73 }
74
Popular Tags