KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 2005 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.MemberValuePair;
14 import org.eclipse.jdt.internal.compiler.ast.NormalAnnotation;
15 import org.eclipse.jdt.internal.compiler.ast.TypeReference;
16 import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
17 import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
18
19 public class CompletionOnAnnotationMemberValuePair extends NormalAnnotation {
20     public MemberValuePair completedMemberValuePair;
21     public CompletionOnAnnotationMemberValuePair(TypeReference type, int sourceStart, MemberValuePair[] memberValuePairs, MemberValuePair completedMemberValuePair) {
22         super(type, sourceStart);
23         this.memberValuePairs = memberValuePairs;
24         this.completedMemberValuePair = completedMemberValuePair;
25     }
26     
27     public TypeBinding resolveType(BlockScope scope) {
28         super.resolveType(scope);
29         
30         if (this.resolvedType == null || !this.resolvedType.isValidBinding()) {
31             throw new CompletionNodeFound();
32         } else {
33             throw new CompletionNodeFound(this.completedMemberValuePair, scope);
34         }
35     }
36     
37     public StringBuffer JavaDoc printExpression(int indent, StringBuffer JavaDoc output) {
38         output.append('@');
39         this.type.printExpression(0, output);
40         output.append('(');
41         if (this.memberValuePairs != null) {
42             for (int i = 0, max = this.memberValuePairs.length; i < max; i++) {
43                 if (i > 0) {
44                     output.append(',');
45                 }
46                 this.memberValuePairs[i].print(indent, output);
47             }
48             output.append(',');
49         }
50         this.completedMemberValuePair.print(indent, output);
51         output.append(')');
52         
53         return output;
54     }
55 }
56
Popular Tags