KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > codeassist > complete > CompletionOnClassLiteralAccess


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.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 org.eclipse.jdt.internal.compiler.ast.*;
35 import org.eclipse.jdt.internal.compiler.lookup.*;
36
37 public class CompletionOnClassLiteralAccess extends ClassLiteralAccess {
38     
39     public char[] completionIdentifier;
40     public int classStart;
41     
42     public CompletionOnClassLiteralAccess(long pos, TypeReference t) {
43         
44         super((int)pos, t);
45         this.classStart = (int) (pos >>> 32);
46     }
47     
48     public StringBuffer JavaDoc printExpression(int indent, StringBuffer JavaDoc output) {
49         
50         output.append("<CompleteOnClassLiteralAccess:"); //$NON-NLS-1$
51
return this.type.print(0, output).append('.').append(this.completionIdentifier).append('>');
52     }
53     
54     public TypeBinding resolveType(BlockScope scope) {
55         
56         if (super.resolveType(scope) == null)
57             throw new CompletionNodeFound();
58         else
59             throw new CompletionNodeFound(this, this.targetType, scope);
60     }
61 }
62
Popular Tags