KickJava   Java API By Example, From Geeks To Geeks.

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


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 import org.eclipse.jdt.core.compiler.CharOperation;
14 import org.eclipse.jdt.internal.compiler.ast.LocalDeclaration;
15 import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
16
17
18 public class CompletionOnLocalName extends LocalDeclaration {
19     private static final char[] FAKENAMESUFFIX = " ".toCharArray(); //$NON-NLS-1$
20
public char[] realName;
21
22     public CompletionOnLocalName(char[] name, int sourceStart, int sourceEnd){
23
24         super(CharOperation.concat(name, FAKENAMESUFFIX), sourceStart, sourceEnd);
25         this.realName = name;
26     }
27     
28     public void resolve(BlockScope scope) {
29         
30         super.resolve(scope);
31         throw new CompletionNodeFound(this, scope);
32     }
33     
34     public StringBuffer JavaDoc printAsExpression(int indent, StringBuffer JavaDoc output) {
35         printIndent(indent, output);
36         output.append("<CompleteOnLocalName:"); //$NON-NLS-1$
37
if (type != null) type.print(0, output).append(' ');
38         output.append(this.realName);
39         if (initialization != null) {
40             output.append(" = "); //$NON-NLS-1$
41
initialization.printExpression(0, output);
42         }
43         return output.append('>');
44     }
45
46     public StringBuffer JavaDoc printStatement(int indent, StringBuffer JavaDoc output) {
47         this.printAsExpression(indent, output);
48         return output.append(';');
49     }
50 }
51
52
Popular Tags