1 11 package org.eclipse.jdt.internal.codeassist.select; 12 13 import org.eclipse.jdt.internal.compiler.ast.*; 14 import org.eclipse.jdt.internal.compiler.lookup.*; 15 16 19 public class SelectionJavadoc extends Javadoc { 20 21 Expression selectedNode; 22 23 public SelectionJavadoc(int sourceStart, int sourceEnd) { 24 super(sourceStart, sourceEnd); 25 } 26 27 30 public StringBuffer print(int indent, StringBuffer output) { 31 super.print(indent, output); 32 if (this.selectedNode != null) { 33 String selectedString = null; 34 if (this.selectedNode instanceof JavadocFieldReference) { 35 JavadocFieldReference fieldRef = (JavadocFieldReference) this.selectedNode; 36 if (fieldRef.methodBinding != null) { 37 selectedString = "<SelectOnMethod:"; } else { 39 selectedString = "<SelectOnField:"; } 41 } else if (this.selectedNode instanceof JavadocMessageSend) { 42 selectedString = "<SelectOnMethod:"; } else if (this.selectedNode instanceof JavadocAllocationExpression) { 44 selectedString = "<SelectOnConstructor:"; } else if (this.selectedNode instanceof JavadocSingleNameReference) { 46 selectedString = "<SelectOnLocalVariable:"; } else if (this.selectedNode instanceof JavadocSingleTypeReference) { 48 JavadocSingleTypeReference typeRef = (JavadocSingleTypeReference) this.selectedNode; 49 if (typeRef.packageBinding == null) { 50 selectedString = "<SelectOnType:"; } 52 } else if (this.selectedNode instanceof JavadocQualifiedTypeReference) { 53 JavadocQualifiedTypeReference typeRef = (JavadocQualifiedTypeReference) this.selectedNode; 54 if (typeRef.packageBinding == null) { 55 selectedString = "<SelectOnType:"; } 57 } else { 58 selectedString = "<SelectOnType:"; } 60 int pos = output.length()-3; 61 output.replace(pos-2,pos, selectedString+selectedNode+'>'); 62 } 63 return output; 64 } 65 66 72 private void internalResolve(Scope scope) { 73 if (this.selectedNode != null) { 74 switch (scope.kind) { 75 case Scope.CLASS_SCOPE: 76 this.selectedNode.resolveType((ClassScope)scope); 77 break; 78 case Scope.METHOD_SCOPE: 79 this.selectedNode.resolveType((MethodScope)scope); 80 break; 81 } 82 Binding binding = null; 83 if (this.selectedNode instanceof JavadocFieldReference) { 84 JavadocFieldReference fieldRef = (JavadocFieldReference) this.selectedNode; 85 binding = fieldRef.binding; 86 if (binding == null && fieldRef.methodBinding != null) { 87 binding = fieldRef.methodBinding; 88 } 89 } else if (this.selectedNode instanceof JavadocMessageSend) { 90 binding = ((JavadocMessageSend) this.selectedNode).binding; 91 } else if (this.selectedNode instanceof JavadocAllocationExpression) { 92 binding = ((JavadocAllocationExpression) this.selectedNode).binding; 93 } else if (this.selectedNode instanceof JavadocSingleNameReference) { 94 binding = ((JavadocSingleNameReference) this.selectedNode).binding; 95 } else if (this.selectedNode instanceof JavadocSingleTypeReference) { 96 JavadocSingleTypeReference typeRef = (JavadocSingleTypeReference) this.selectedNode; 97 if (typeRef.packageBinding == null) { 98 binding = typeRef.resolvedType; 99 } 100 } else if (this.selectedNode instanceof JavadocQualifiedTypeReference) { 101 JavadocQualifiedTypeReference typeRef = (JavadocQualifiedTypeReference) this.selectedNode; 102 if (typeRef.packageBinding == null) { 103 binding = typeRef.resolvedType; 104 } 105 } else { 106 binding = this.selectedNode.resolvedType; 107 } 108 throw new SelectionNodeFound(binding); 109 } 110 } 111 112 118 public void resolve(ClassScope scope) { 119 internalResolve(scope); 120 } 121 122 128 public void resolve(MethodScope scope) { 129 internalResolve(scope); 130 } 131 132 } 133 | Popular Tags |