Example usage for org.eclipse.jdt.core IJavaModelStatusConstants INDEX_OUT_OF_BOUNDS

List of usage examples for org.eclipse.jdt.core IJavaModelStatusConstants INDEX_OUT_OF_BOUNDS

Introduction

In this page you can find the example usage for org.eclipse.jdt.core IJavaModelStatusConstants INDEX_OUT_OF_BOUNDS.

Prototype

int INDEX_OUT_OF_BOUNDS

To view the source code for org.eclipse.jdt.core IJavaModelStatusConstants INDEX_OUT_OF_BOUNDS.

Click Source Link

Document

Status constant indicating the given source position is out of bounds.

Usage

From source file:org.eclipse.ajdt.core.javaelements.AJCompilationUnit.java

License:Open Source License

/**
* this method is a copy of {@link Openable#codeComplete(org.eclipse.jdt.internal.compiler.env.ICompilationUnit, org.eclipse.jdt.internal.compiler.env.ICompilationUnit, int, CompletionRequestor, WorkingCopyOwner, ITypeRoot)}
* The only change is that we need to create an {@link ITDAwareNameEnvironment}, not  standard {@link SearchableEnvironment}.
 * //from  w ww .  j  a va  2s . c om
* @param cu
* @param unitToSkip
* @param position
* @param requestor
* @param owner
* @param typeRoot
* @throws JavaModelException
*/
private void internalCodeComplete(org.eclipse.jdt.internal.compiler.env.ICompilationUnit cu,
        org.eclipse.jdt.internal.compiler.env.ICompilationUnit unitToSkip, int position,
        CompletionRequestor requestor, WorkingCopyOwner owner, ITypeRoot typeRoot,
        /* AJDT 1.7 */
        IProgressMonitor monitor) throws JavaModelException {

    if (requestor == null) {
        throw new IllegalArgumentException("Completion requestor cannot be null"); //$NON-NLS-1$
    }
    PerformanceStats performanceStats = CompletionEngine.PERF
            ? PerformanceStats.getStats(JavaModelManager.COMPLETION_PERF, this)
            : null;
    if (performanceStats != null) {
        performanceStats.startRun(new String(cu.getFileName()) + " at " + position); //$NON-NLS-1$
    }
    IBuffer buffer = getBuffer();
    if (buffer == null) {
        return;
    }
    if (position < -1 || position > buffer.getLength()) {
        throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.INDEX_OUT_OF_BOUNDS));
    }
    JavaProject project = (JavaProject) getJavaProject();
    /* AJDT 1.7 */
    ITDAwareNameEnvironment environment = new ITDAwareNameEnvironment(project, owner, monitor);

    environment.setUnitToSkip(unitToSkip);

    // code complete
    /* AJDT 1.7 */
    CompletionEngine engine = new CompletionEngine(environment, requestor, project.getOptions(true), project,
            owner, monitor);
    engine.complete(cu, position, 0, typeRoot);
    if (performanceStats != null) {
        performanceStats.endRun();
    }
    if (NameLookup.VERBOSE) {
        AJLog.log(Thread.currentThread() + " TIME SPENT in NameLoopkup#seekTypesInSourcePackage: " //$NON-NLS-1$
                + environment.nameLookup.timeSpentInSeekTypesInSourcePackage + "ms"); //$NON-NLS-1$
        AJLog.log(Thread.currentThread() + " TIME SPENT in NameLoopkup#seekTypesInBinaryPackage: " //$NON-NLS-1$
                + environment.nameLookup.timeSpentInSeekTypesInBinaryPackage + "ms"); //$NON-NLS-1$
    }

}

From source file:org.eclipse.ajdt.internal.core.contentassist.ContentAssistProvider.java

License:Open Source License

public boolean doContentAssist(ICompilationUnit cu, ICompilationUnit unitToSkip, int position,
        CompletionRequestor requestor, WorkingCopyOwner owner,
        /* AJDT 1.7 */
        ITypeRoot typeRoot, Openable target, IProgressMonitor monitor) throws Exception {
    JavaProject project = (JavaProject) target.getJavaProject();
    if (!AspectJPlugin.isAJProject(project.getProject())) {
        return false;
    }/*  w ww .j a va 2 s  .c o  m*/
    if (target instanceof AJCompilationUnit) {
        // already handled by the compilation unit
        return false;
    }
    if (!(target instanceof CompilationUnit)) {
        return false;
    }
    IBuffer buffer = target.getBuffer();
    if (buffer == null) {
        return false;
    }

    if (requestor == null) {
        throw new IllegalArgumentException("Completion requestor cannot be null"); //$NON-NLS-1$
    }

    MockCompilationUnit mcu = new MockCompilationUnit((CompilationUnit) target);
    ProposalRequestorWrapper wrapped = new ProposalRequestorWrapper(requestor, mcu, mcu.insertionTable);
    int transformedPos = mcu.translatePositionToFake(position);
    if (transformedPos < -1 || transformedPos > mcu.getContents().length) {
        throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.INDEX_OUT_OF_BOUNDS));
    }

    /* AJDT 1.7 */
    ITDAwareNameEnvironment environment = new ITDAwareNameEnvironment(project, owner, monitor);
    environment.setUnitToSkip(unitToSkip);

    // code complete
    /* AJDT 1.7 */
    CompletionEngine engine = new CompletionEngine(environment, wrapped, project.getOptions(true), project,
            owner, monitor);
    engine.lookupEnvironment = new ITDAwareLookupEnvironment(engine.lookupEnvironment, environment);
    engine.complete(mcu, transformedPos, 0, typeRoot);

    return true;
}

From source file:org.eclipse.jdt.internal.core.CopyResourceElementsOperation.java

License:Open Source License

/**
 * Possible failures:// w w  w .ja  va  2  s  .co  m
 * <ul>
 *  <li>NO_ELEMENTS_TO_PROCESS - no elements supplied to the operation
 *   <li>INDEX_OUT_OF_BOUNDS - the number of renamings supplied to the operation
 *      does not match the number of elements that were supplied.
 * </ul>
 */
protected IJavaModelStatus verify() {
    IJavaModelStatus status = super.verify();
    if (!status.isOK()) {
        return status;
    }

    if (this.renamingsList != null && this.renamingsList.length != this.elementsToProcess.length) {
        return new JavaModelStatus(IJavaModelStatusConstants.INDEX_OUT_OF_BOUNDS);
    }
    return JavaModelStatus.VERIFIED_OK;
}