Example usage for org.eclipse.jdt.core.compiler CharOperation prefixEquals

List of usage examples for org.eclipse.jdt.core.compiler CharOperation prefixEquals

Introduction

In this page you can find the example usage for org.eclipse.jdt.core.compiler CharOperation prefixEquals.

Prototype

public static final boolean prefixEquals(char[] prefix, char[] name, boolean isCaseSensitive, int startIndex) 

Source Link

Document

Answers true if the given name, starting from the given index, starts with the given prefix, false otherwise.

Usage

From source file:com.codenvy.ide.ext.java.server.internal.core.JavadocContents.java

License:Open Source License

private int[] computeChildRange(char[] anchor, int indexOfSectionBottom) throws JavaModelException {

    // checks each known anchor locations
    if (this.tempAnchorIndexesCount > 0) {
        for (int i = 0; i < this.tempAnchorIndexesCount; i++) {
            int anchorEndStart = this.tempAnchorIndexes[i];

            if (anchorEndStart != -1
                    && CharOperation.prefixEquals(anchor, this.content, false, anchorEndStart)) {

                this.tempAnchorIndexes[i] = -1;

                return computeChildRange(anchorEndStart, anchor, indexOfSectionBottom);
            }//from w  ww.j  ava 2  s. c o m
        }
    }

    int fromIndex = this.tempLastAnchorFoundIndex;
    int index;

    // check each next unknown anchor locations
    while ((index = CharOperation.indexOf(JavadocConstants.ANCHOR_PREFIX_START, this.content, false,
            fromIndex)) != -1 && (index < indexOfSectionBottom || indexOfSectionBottom == -1)) {
        fromIndex = index + 1;

        int anchorEndStart = index + JavadocConstants.ANCHOR_PREFIX_START_LENGHT;

        this.tempLastAnchorFoundIndex = anchorEndStart;

        if (CharOperation.prefixEquals(anchor, this.content, false, anchorEndStart)) {
            return computeChildRange(anchorEndStart, anchor, indexOfSectionBottom);
        } else {
            if (this.tempAnchorIndexes.length == this.tempAnchorIndexesCount) {
                System.arraycopy(this.tempAnchorIndexes, 0,
                        this.tempAnchorIndexes = new int[this.tempAnchorIndexesCount + 20], 0,
                        this.tempAnchorIndexesCount);
            }

            this.tempAnchorIndexes[this.tempAnchorIndexesCount++] = anchorEndStart;
        }
    }

    return null;
}