a231960cde2d097c1b3dec93612f5d6f90397218
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / codeassist / select / SelectionOnExplicitConstructorCall.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.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 net.sourceforge.phpdt.internal.compiler.ast.ExplicitConstructorCall;
33 import net.sourceforge.phpdt.internal.compiler.lookup.BlockScope;
34 import net.sourceforge.phpdt.internal.compiler.lookup.ProblemReasons;
35
36 public class SelectionOnExplicitConstructorCall extends ExplicitConstructorCall {
37 public SelectionOnExplicitConstructorCall(int accessMode) {
38         super(accessMode);
39 }
40 public void resolve(BlockScope scope) {
41         super.resolve(scope);
42
43         // tolerate some error cases
44         if (binding == null || 
45                         !(binding.isValidBinding() ||
46                                 binding.problemId() == ProblemReasons.NotVisible))
47                 throw new SelectionNodeFound();
48         else
49                 throw new SelectionNodeFound(binding);
50 }
51 public String toString(int tab) {
52         String s = tabString(tab);
53         s += "<SelectOnExplicitConstructorCall:"; //$NON-NLS-1$
54         if (qualification != null)
55                 s = s + qualification.toStringExpression() + "."; //$NON-NLS-1$
56         if (accessMode == This) {
57                 s = s + "this("; //$NON-NLS-1$
58         } else {
59                 s = s + "super("; //$NON-NLS-1$
60         }
61         if (arguments != null) {
62                 for (int i = 0; i < arguments.length; i++) {
63                         s += arguments[i].toStringExpression();
64                         if (i != arguments.length - 1) {
65                                 s += ", "; //$NON-NLS-1$
66                         }
67                 };
68         }
69         s += ")>"; //$NON-NLS-1$
70         return s;
71 }
72 }