Lines 19-24
Link Here
|
19 |
import org.eclipse.jdt.core.JavaModelException; |
19 |
import org.eclipse.jdt.core.JavaModelException; |
20 |
import org.eclipse.jdt.core.WorkingCopyOwner; |
20 |
import org.eclipse.jdt.core.WorkingCopyOwner; |
21 |
import org.eclipse.jdt.core.compiler.CharOperation; |
21 |
import org.eclipse.jdt.core.compiler.CharOperation; |
|
|
22 |
import org.eclipse.jdt.internal.codeassist.complete.CompletionNodeDetector; |
22 |
import org.eclipse.jdt.internal.codeassist.complete.CompletionParser; |
23 |
import org.eclipse.jdt.internal.codeassist.complete.CompletionParser; |
23 |
import org.eclipse.jdt.internal.codeassist.impl.AssistCompilationUnit; |
24 |
import org.eclipse.jdt.internal.codeassist.impl.AssistCompilationUnit; |
24 |
import org.eclipse.jdt.internal.compiler.ast.ASTNode; |
25 |
import org.eclipse.jdt.internal.compiler.ast.ASTNode; |
Lines 186-234
Link Here
|
186 |
break done; |
187 |
break done; |
187 |
} |
188 |
} |
188 |
} else { |
189 |
} else { |
189 |
FieldDeclaration fieldDeclaration = fields[i]; |
190 |
FieldDeclaration fieldDeclaration = fields[i]; |
190 |
if (fieldDeclaration.initialization != null) { |
191 |
if (fieldDeclaration.initialization != null) { |
191 |
// completion is inside a field initializer |
192 |
boolean isInsideInitializer = false; |
192 |
searchVisibleVariablesAndMethods(scope, this.visibleLocalVariables, this.visibleFields, this.visibleMethods, notInJavadoc); |
|
|
193 |
// remove this field from visibleFields list because completion is being asked in its |
194 |
// intialization and so this has not yet been declared successfully. |
195 |
if (this.visibleFields.size > 0 && this.visibleFields.contains(fieldDeclaration.binding)) { |
196 |
this.visibleFields.remove(fieldDeclaration.binding); |
197 |
} |
198 |
int count = 0; |
199 |
while (count < this.visibleFields.size) { |
200 |
FieldBinding visibleField = (FieldBinding)this.visibleFields.elementAt(count); |
201 |
if (visibleField.id > fieldDeclaration.binding.id) { |
202 |
this.visibleFields.remove(visibleField); |
203 |
continue; |
204 |
} |
205 |
count++; |
206 |
} |
207 |
break done; |
208 |
} |
209 |
/*(Incase fieldDeclaration != null is not sufficient to infer that |
210 |
proposal is being asked inside initializer of field decl, use the below if |
211 |
block instead of the above) |
212 |
if (fieldDeclaration.initialization != null) { |
213 |
|
214 |
if (fieldDeclaration.initialization.sourceEnd > 0) { |
193 |
if (fieldDeclaration.initialization.sourceEnd > 0) { |
215 |
if (fieldDeclaration.initialization.sourceStart <= astNode.sourceStart && |
194 |
if (fieldDeclaration.initialization.sourceStart <= astNode.sourceStart && |
216 |
astNode.sourceEnd <= fieldDeclaration.initialization.sourceEnd) { |
195 |
astNode.sourceEnd <= fieldDeclaration.initialization.sourceEnd) { |
217 |
// completion is inside a field initializer |
196 |
// completion is inside a field initializer |
218 |
searchVisibleVariablesAndMethods(scope, this.visibleLocalVariables, this.visibleFields, this.visibleMethods, notInJavadoc); |
197 |
isInsideInitializer = true; |
219 |
} |
198 |
} |
220 |
} else { // The sourceEnd may not yet be set |
199 |
} else { // The sourceEnd may not yet be set |
221 |
CompletionNodeDetector detector = new CompletionNodeDetector(this.assistNode, fieldDeclaration.initialization); |
200 |
CompletionNodeDetector detector = new CompletionNodeDetector(this.assistNode, fieldDeclaration.initialization); |
222 |
if (detector.containsCompletionNode()) { |
201 |
if (detector.containsCompletionNode()) { |
223 |
searchVisibleVariablesAndMethods(scope, this.visibleLocalVariables, this.visibleFields, this.visibleMethods, notInJavadoc); |
202 |
// completion is inside a field initializer |
|
|
203 |
isInsideInitializer = true; |
224 |
} |
204 |
} |
225 |
} |
205 |
} |
226 |
// remove this field from visibleFields list because completion is being asked in its |
206 |
if (isInsideInitializer) { |
227 |
// intialization and so this has not yet been declared successfully. |
207 |
searchVisibleVariablesAndMethods(scope, this.visibleLocalVariables, this.visibleFields, this.visibleMethods, notInJavadoc); |
228 |
if (this.visibleFields.size > 0 && this.visibleFields.contains(fieldDeclaration.binding)) { |
208 |
// remove this field from visibleFields list because completion is being asked in its |
229 |
this.visibleFields.remove(fieldDeclaration.binding); |
209 |
// intialization and so this has not yet been declared successfully. |
|
|
210 |
if (this.visibleFields.size > 0 && this.visibleFields.contains(fieldDeclaration.binding)) { |
211 |
this.visibleFields.remove(fieldDeclaration.binding); |
212 |
} |
213 |
int count = 0; |
214 |
while (count < this.visibleFields.size) { |
215 |
FieldBinding visibleField = (FieldBinding)this.visibleFields.elementAt(count); |
216 |
if (visibleField.id > fieldDeclaration.binding.id) { |
217 |
this.visibleFields.remove(visibleField); |
218 |
continue; |
219 |
} |
220 |
count++; |
221 |
} |
222 |
break done; |
230 |
} |
223 |
} |
231 |
}*/ |
224 |
} |
232 |
} |
225 |
} |
233 |
} |
226 |
} |
234 |
} |
227 |
} |