Switched to Eclipse 2.1 development; eliminated JTidy package => now standalone plugin
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / codeassist / complete / CompletionOnClassLiteralAccess.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.complete;
12
13 /*
14  * Completion node build by the parser in any case it was intending to
15  * reduce an access to the literal 'class' containing the cursor.
16  * e.g.
17  *
18  *      class X {
19  *    void foo() {
20  *      String[].[cursor]
21  *    }
22  *  }
23  *
24  *      ---> class X {
25  *         void foo() {
26  *           <CompleteOnClassLiteralAccess:String[].>
27  *         }
28  *       }
29  *
30  * The source range of the completion node denotes the source range
31  * which should be replaced by the completion.
32  */
33
34 import net.sourceforge.phpdt.internal.compiler.ast.ClassLiteralAccess;
35 import net.sourceforge.phpdt.internal.compiler.ast.TypeReference;
36 import net.sourceforge.phpdt.internal.compiler.lookup.BlockScope;
37 import net.sourceforge.phpdt.internal.compiler.lookup.TypeBinding;
38
39 public class CompletionOnClassLiteralAccess extends ClassLiteralAccess {
40         public char[] completionIdentifier;
41         public int classStart;
42         
43 public CompletionOnClassLiteralAccess(long pos, TypeReference t) {
44         super((int)pos, t);
45         this.classStart = (int) (pos >>> 32);
46 }
47 public TypeBinding resolveType(BlockScope scope) {
48         if (super.resolveType(scope) == null)
49                 throw new CompletionNodeFound();
50         else
51                 throw new CompletionNodeFound(this, targetType, scope);
52 }
53 public String toStringExpression() {
54         StringBuffer result = new StringBuffer("<CompleteOnClassLiteralAccess:"); //$NON-NLS-1$
55         result.append(type.toString());
56         result.append("."); //$NON-NLS-1$
57         result.append(completionIdentifier);
58         result.append(">"); //$NON-NLS-1$
59         return result.toString();
60 }
61 }