KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 2005 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.internal.compiler.ast.StringLiteral;
14 import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
15 import org.eclipse.jdt.internal.compiler.lookup.ClassScope;
16 import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
17
18 /*
19  * Completion node build by the parser in any case it was intending to
20  * reduce a string literal.
21  * e.g.
22  *
23  * class X {
24  * void foo() {
25  * String s = "a[cursor]"
26  * }
27  * }
28  *
29  * ---> class X {
30  * void foo() {
31  * String s = <CompleteOnStringLiteral:a>
32  * }
33  * }
34  */

35
36 public class CompletionOnStringLiteral extends StringLiteral {
37     public int contentStart;
38     public int contentEnd;
39     public CompletionOnStringLiteral(char[] token, int s, int e, int cs, int ce, int lineNumber) {
40         super(token, s, e, lineNumber);
41         this.contentStart = cs;
42         this.contentEnd = ce;
43     }
44
45     public CompletionOnStringLiteral(int s, int e, int cs, int ce) {
46         super(s,e);
47         this.contentStart = cs;
48         this.contentEnd = ce;
49     }
50     public TypeBinding resolveType(ClassScope scope) {
51         throw new CompletionNodeFound(this, null, scope);
52     }
53     public TypeBinding resolveType(BlockScope scope) {
54         throw new CompletionNodeFound(this, null, scope);
55     }
56     
57     public StringBuffer JavaDoc printExpression(int indent, StringBuffer JavaDoc output) {
58         output.append("<CompletionOnString:"); //$NON-NLS-1$
59
output = super.printExpression(indent, output);
60         return output.append('>');
61     }
62 }
63
Popular Tags