KickJava   Java API By Example, From Geeks To Geeks.

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


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