KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 2004, 2006 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.MarkerAnnotation;
14 import org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference;
15 import org.eclipse.jdt.internal.compiler.ast.TypeReference;
16 import org.eclipse.jdt.internal.compiler.lookup.Binding;
17 import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
18 import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
19
20 public class CompletionOnMarkerAnnotationName extends MarkerAnnotation {
21     public CompletionOnMarkerAnnotationName(TypeReference type, int sourceStart){
22         super(type, sourceStart);
23     }
24     
25     public TypeBinding resolveType(BlockScope scope) {
26         if(type instanceof QualifiedTypeReference) {
27             QualifiedTypeReference qualifiedTypeReference = (QualifiedTypeReference) type;
28             Binding binding = scope.parent.getTypeOrPackage(qualifiedTypeReference.tokens); // step up from the ClassScope
29
if (!binding.isValidBinding()) {
30                 scope.problemReporter().invalidType(this, (TypeBinding) binding);
31                 throw new CompletionNodeFound();
32             }
33             throw new CompletionNodeFound(this, binding, scope);
34         }
35         throw new CompletionNodeFound(this, null, scope);
36     }
37 }
38
Popular Tags