use of org.eclipse.jdt.internal.codeassist.CompletionEngine in project eclipse.jdt.ls by eclipse.
the class ModelBasedCompletionEngine method codeComplete.
public static void codeComplete(ICompilationUnit cu, int position, CompletionRequestor requestor, WorkingCopyOwner owner, IProgressMonitor monitor) throws JavaModelException {
if (!(cu instanceof CompilationUnit)) {
return;
}
if (requestor == null) {
// $NON-NLS-1$
throw new IllegalArgumentException("Completion requestor cannot be null");
}
IBuffer buffer = cu.getBuffer();
if (buffer == null) {
return;
}
if (position < -1 || position > buffer.getLength()) {
throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.INDEX_OUT_OF_BOUNDS));
}
JavaProject project = (JavaProject) cu.getJavaProject();
ModelBasedSearchableEnvironment environment = new ModelBasedSearchableEnvironment(project, owner, requestor.isTestCodeExcluded());
environment.setUnitToSkip((CompilationUnit) cu);
// code complete
CompletionEngine engine = new CompletionEngine(environment, requestor, project.getOptions(true), project, owner, monitor);
engine.complete((CompilationUnit) cu, position, 0, cu);
}
Aggregations