KickJava   Java API By Example, From Geeks To Geeks.

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


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 a single name reference containing the completion identifier.
16  * e.g.
17  *
18  * class X {
19  * void foo() {
20  * ba[cursor]
21  * }
22  * }
23  *
24  * ---> class X {
25  * void foo() {
26  * <CompleteOnName:ba>
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 CompletionOnSingleNameReference extends SingleNameReference {
38
39     public char[][] possibleKeywords;
40     public boolean canBeExplicitConstructor;
41     public boolean isInsideAnnotationAttribute;
42
43     public CompletionOnSingleNameReference(char[] source, long pos, boolean isInsideAnnotationAttribute) {
44         this(source, pos, null, false, isInsideAnnotationAttribute);
45     }
46
47     public CompletionOnSingleNameReference(char[] source, long pos, char[][] possibleKeywords, boolean canBeExplicitConstructor, boolean isInsideAnnotationAttribute) {
48         super(source, pos);
49         this.possibleKeywords = possibleKeywords;
50         this.canBeExplicitConstructor = canBeExplicitConstructor;
51         this.isInsideAnnotationAttribute = isInsideAnnotationAttribute;
52     }
53
54     public StringBuffer JavaDoc printExpression(int indent, StringBuffer JavaDoc output) {
55         
56         output.append("<CompleteOnName:"); //$NON-NLS-1$
57
return super.printExpression(0, output).append('>');
58     }
59
60     public TypeBinding resolveType(BlockScope scope) {
61         if(scope instanceof MethodScope) {
62             throw new CompletionNodeFound(this, scope, ((MethodScope)scope).insideTypeAnnotation);
63         }
64         throw new CompletionNodeFound(this, scope);
65     }
66 }
67
Popular Tags