1 11 package org.eclipse.jdt.internal.codeassist.complete; 12 13 import org.eclipse.jdt.internal.compiler.ast.Expression; 14 import org.eclipse.jdt.internal.compiler.ast.JavadocFieldReference; 15 import org.eclipse.jdt.internal.compiler.ast.JavadocMessageSend; 16 import org.eclipse.jdt.internal.compiler.lookup.BlockScope; 17 import org.eclipse.jdt.internal.compiler.lookup.ClassScope; 18 import org.eclipse.jdt.internal.compiler.lookup.Scope; 19 import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; 20 21 public class CompletionOnJavadocFieldReference extends JavadocFieldReference implements CompletionOnJavadoc { 22 public int completionFlags = JAVADOC; 24 public int separatorPosition; 25 26 public CompletionOnJavadocFieldReference(Expression receiver, int tag, int position, int separatorPos, char[] name) { 27 super(null, (((long)position)<<32)+position-1); 28 this.receiver = receiver; 29 this.tagSourceStart = position; 30 this.tagSourceEnd = position; 31 this.tagValue = tag; 32 this.separatorPosition = separatorPos; 33 } 34 35 public CompletionOnJavadocFieldReference(JavadocFieldReference fieldRef, int position, char[] name) { 36 super(fieldRef.token, fieldRef.nameSourcePosition); 37 this.receiver = fieldRef.receiver; 38 this.separatorPosition = position; 39 this.tagSourceStart = fieldRef.tagSourceStart; 40 this.tagSourceEnd = fieldRef.tagSourceEnd; 41 this.tagValue = fieldRef.tagValue; 42 } 43 44 public CompletionOnJavadocFieldReference(JavadocMessageSend msgSend, int position) { 45 super(msgSend.selector, ((msgSend.nameSourcePosition>>32)<<32)+msgSend.sourceEnd); 46 this.receiver = msgSend.receiver; 47 this.separatorPosition = position; 48 this.tagSourceStart = msgSend.tagSourceStart; 49 this.tagSourceEnd = msgSend.tagSourceEnd; 50 this.tagValue = msgSend.tagValue; 51 } 52 53 56 public void addCompletionFlags(int flags) { 57 this.completionFlags |= flags; 58 } 59 60 public boolean completeAnException() { 61 return (this.completionFlags & EXCEPTION) != 0; 62 } 63 64 public boolean completeInText() { 65 return (this.completionFlags & TEXT) != 0; 66 } 67 68 public boolean completeBaseTypes() { 69 return (this.completionFlags & BASE_TYPES) != 0; 70 } 71 72 public boolean completeFormalReference() { 73 return (this.completionFlags & FORMAL_REFERENCE) != 0; 74 } 75 76 81 public int getCompletionFlags() { 82 return this.completionFlags; 83 } 84 85 88 protected TypeBinding internalResolveType(Scope scope) { 89 90 if (this.token != null) { 91 return super.internalResolveType(scope); 92 } 93 94 if (this.receiver == null) { 96 this.receiverType = scope.enclosingSourceType(); 97 } else if (scope.kind == Scope.CLASS_SCOPE) { 98 this.receiverType = this.receiver.resolveType((ClassScope) scope); 99 } else { 100 this.receiverType = this.receiver.resolveType((BlockScope)scope); 101 } 102 return null; 103 } 104 105 108 public StringBuffer printExpression(int indent, StringBuffer output) { 109 output.append("<CompleteOnJavadocFieldReference:"); super.printExpression(indent, output); 111 indent++; 112 if (this.completionFlags > 0) { 113 output.append('\n'); 114 for (int i=0; i<indent; i++) output.append('\t'); 115 output.append("infos:"); char separator = 0; 117 if (completeAnException()) { 118 output.append("exception"); separator = ','; 120 } 121 if (completeInText()) { 122 if (separator != 0) output.append(separator); 123 output.append("text"); separator = ','; 125 } 126 if (completeBaseTypes()) { 127 if (separator != 0) output.append(separator); 128 output.append("base types"); separator = ','; 130 } 131 if (completeFormalReference()) { 132 if (separator != 0) output.append(separator); 133 output.append("formal reference"); separator = ','; 135 } 136 output.append('\n'); 137 } 138 indent--; 139 for (int i=0; i<indent; i++) output.append('\t'); 140 return output.append('>'); 141 } 142 } 143 | Popular Tags |