if (requestor == null) {
throw new IllegalArgumentException("Completion requestor cannot be null"); //$NON-NLS-1$
}
JavaProject project = (JavaProject) getJavaProject();
SearchableEnvironment environment = project.newSearchableNameEnvironment(owner);
CompletionEngine engine = new CompletionEngine(environment, requestor, project.getOptions(true), project, owner, monitor);
String source = getClassFile().getSource();
if (source != null && insertion > -1 && insertion < source.length()) {
// code complete
char[] prefix = CharOperation.concat(source.substring(0, insertion).toCharArray(), new char[]{'{'});
char[] suffix = CharOperation.concat(new char[]{'}'}, source.substring(insertion).toCharArray());
char[] fakeSource = CharOperation.concat(prefix, snippet, suffix);
BasicCompilationUnit cu =
new BasicCompilationUnit(
fakeSource,
null,
getElementName(),
project); // use project to retrieve corresponding .java IFile
engine.complete(cu, prefix.length + position, prefix.length, null/*extended context isn't computed*/);
} else {
engine.complete(this, snippet, position, localVariableTypeNames, localVariableNames, localVariableModifiers, isStatic);
}
if (NameLookup.VERBOSE) {
System.out.println(Thread.currentThread() + " TIME SPENT in NameLoopkup#seekTypesInSourcePackage: " + environment.nameLookup.timeSpentInSeekTypesInSourcePackage + "ms"); //$NON-NLS-1$ //$NON-NLS-2$
System.out.println(Thread.currentThread() + " TIME SPENT in NameLoopkup#seekTypesInBinaryPackage: " + environment.nameLookup.timeSpentInSeekTypesInBinaryPackage + "ms"); //$NON-NLS-1$ //$NON-NLS-2$
}