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.*;
 
  28 import net.sourceforge.phpdt.internal.compiler.lookup.*;
 
  30 public class CompletionOnQualifiedTypeReference extends QualifiedTypeReference {
 
  31         public char[] completionIdentifier;
 
  32 public CompletionOnQualifiedTypeReference(char[][] previousIdentifiers, char[] completionIdentifier, long[] positions) {
 
  33         super(previousIdentifiers, positions);
 
  34         this.completionIdentifier = completionIdentifier;
 
  36 public void aboutToResolve(Scope scope) {
 
  37         getTypeBinding(scope);
 
  40  * No expansion of the completion reference into an array one
 
  42 public TypeReference copyDims(int dim){
 
  45 public TypeBinding getTypeBinding(Scope scope) {
 
  46         // it can be a package, type or member type
 
  47         Binding binding = scope.parent.getTypeOrPackage(tokens); // step up from the ClassScope
 
  48         if (!binding.isValidBinding()) {
 
  49                 scope.problemReporter().invalidType(this, (TypeBinding) binding);
 
  50                 throw new CompletionNodeFound();
 
  53         throw new CompletionNodeFound(this, binding, scope);
 
  55 public String toStringExpression(int tab) {
 
  57         StringBuffer buffer = new StringBuffer();
 
  58         buffer.append("<CompleteOnType:"); //$NON-NLS-1$
 
  59         for (int i = 0; i < tokens.length; i++) {
 
  60                 buffer.append(tokens[i]);
 
  61                 buffer.append("."); //$NON-NLS-1$
 
  63         buffer.append(completionIdentifier).append(">"); //$NON-NLS-1$
 
  64         return buffer.toString();