1 /*******************************************************************************
2 * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v0.5
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v05.html
9 * IBM Corporation - initial API and implementation
10 ******************************************************************************/
11 package net.sourceforge.phpdt.internal.codeassist.complete;
14 * Completion node build by the parser in any case it was intending to
15 * reduce a type reference containing the completion identifier as part
16 * of a qualified name.
19 * class X extends java.lang.Obj[cursor]
21 * ---> class X extends <CompleteOnType:java.lang.Obj>
23 * The source range of the completion node denotes the source range
24 * which should be replaced by the completion.
27 import net.sourceforge.phpdt.internal.compiler.ast.QualifiedTypeReference;
28 import net.sourceforge.phpdt.internal.compiler.ast.TypeReference;
29 import net.sourceforge.phpdt.internal.compiler.lookup.Binding;
30 import net.sourceforge.phpdt.internal.compiler.lookup.Scope;
31 import net.sourceforge.phpdt.internal.compiler.lookup.TypeBinding;
33 public class CompletionOnQualifiedTypeReference extends QualifiedTypeReference {
34 public char[] completionIdentifier;
35 public CompletionOnQualifiedTypeReference(char[][] previousIdentifiers, char[] completionIdentifier, long[] positions) {
36 super(previousIdentifiers, positions);
37 this.completionIdentifier = completionIdentifier;
39 public void aboutToResolve(Scope scope) {
40 getTypeBinding(scope);
43 * No expansion of the completion reference into an array one
45 public TypeReference copyDims(int dim){
48 public TypeBinding getTypeBinding(Scope scope) {
49 // it can be a package, type or member type
50 Binding binding = scope.parent.getTypeOrPackage(tokens); // step up from the ClassScope
51 if (!binding.isValidBinding()) {
52 scope.problemReporter().invalidType(this, (TypeBinding) binding);
53 throw new CompletionNodeFound();
56 throw new CompletionNodeFound(this, binding, scope);
58 public String toStringExpression(int tab) {
60 StringBuffer buffer = new StringBuffer();
61 buffer.append("<CompleteOnType:"); //$NON-NLS-1$
62 for (int i = 0; i < tokens.length; i++) {
63 buffer.append(tokens[i]);
64 buffer.append("."); //$NON-NLS-1$
66 buffer.append(completionIdentifier).append(">"); //$NON-NLS-1$
67 return buffer.toString();