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.select;
14 * Selection 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.[start]Object[end]
21 * ---> class X extends <SelectOnType:java.lang.Object>
25 import net.sourceforge.phpdt.internal.compiler.ast.QualifiedTypeReference;
26 import net.sourceforge.phpdt.internal.compiler.lookup.Binding;
27 import net.sourceforge.phpdt.internal.compiler.lookup.ProblemReasons;
28 import net.sourceforge.phpdt.internal.compiler.lookup.Scope;
29 import net.sourceforge.phpdt.internal.compiler.lookup.TypeBinding;
30 import net.sourceforge.phpdt.internal.compiler.util.CharOperation;
32 public class SelectionOnQualifiedTypeReference extends QualifiedTypeReference {
33 public SelectionOnQualifiedTypeReference(char[][] previousIdentifiers, char[] selectionIdentifier, long[] positions) {
35 CharOperation.arrayConcat(previousIdentifiers, selectionIdentifier),
38 public void aboutToResolve(Scope scope) {
39 getTypeBinding(scope.parent); // step up from the ClassScope
41 public TypeBinding getTypeBinding(Scope scope) {
42 // it can be a package, type or member type
43 Binding binding = scope.getTypeOrPackage(tokens);
44 if (!binding.isValidBinding()) {
45 // tolerate some error cases
46 if (binding.problemId() == ProblemReasons.NotVisible){
47 throw new SelectionNodeFound(binding);
49 scope.problemReporter().invalidType(this, (TypeBinding) binding);
50 throw new SelectionNodeFound();
53 throw new SelectionNodeFound(binding);
55 public String toStringExpression(int tab) {
57 StringBuffer buffer = new StringBuffer();
58 buffer.append("<SelectOnType:"); //$NON-NLS-1$
59 for (int i = 0, length = tokens.length; i < length; i++) {
60 buffer.append(tokens[i]);
62 buffer.append("."); //$NON-NLS-1$
64 buffer.append(">"); //$NON-NLS-1$
65 return buffer.toString();