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 a single
 
  19  *      class X extends Obj[cursor]
 
  21  *      ---> class X extends <CompleteOnType: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.SingleTypeReference;
 
  28 import net.sourceforge.phpdt.internal.compiler.ast.TypeReference;
 
  29 import net.sourceforge.phpdt.internal.compiler.lookup.BlockScope;
 
  30 import net.sourceforge.phpdt.internal.compiler.lookup.ReferenceBinding;
 
  31 import net.sourceforge.phpdt.internal.compiler.lookup.Scope;
 
  32 import net.sourceforge.phpdt.internal.compiler.lookup.TypeBinding;
 
  34 public class CompletionOnSingleTypeReference extends SingleTypeReference {
 
  35 public boolean isCompletionNode;
 
  36 public CompletionOnSingleTypeReference(char[] source, long pos) {
 
  38         isCompletionNode = true;
 
  40 public void aboutToResolve(Scope scope) {
 
  41         getTypeBinding(scope);
 
  44  * No expansion of the completion reference into an array one
 
  46 public TypeReference copyDims(int dim){
 
  49 public TypeBinding getTypeBinding(Scope scope) {
 
  50         if(isCompletionNode) {
 
  51                 throw new CompletionNodeFound(this, scope);
 
  53                 return super.getTypeBinding(scope);
 
  56 public TypeBinding resolveTypeEnclosing(BlockScope scope, ReferenceBinding enclosingType) {
 
  57         if(isCompletionNode) {
 
  58                 throw new CompletionNodeFound(this, enclosingType, scope);
 
  60                 return super.resolveTypeEnclosing(scope, enclosingType);
 
  63 public String toStringExpression(int tab){
 
  65         return "<CompleteOnType:" + new String(token) + ">" ; //$NON-NLS-2$ //$NON-NLS-1$