Example usage for org.eclipse.jdt.internal.core JavadocConstants NESTED_CLASS_SUMMARY

List of usage examples for org.eclipse.jdt.internal.core JavadocConstants NESTED_CLASS_SUMMARY

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.core JavadocConstants NESTED_CLASS_SUMMARY.

Prototype

null NESTED_CLASS_SUMMARY

To view the source code for org.eclipse.jdt.internal.core JavadocConstants NESTED_CLASS_SUMMARY.

Click Source Link

Usage

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

License:Open Source License

private void computeTypeRange() throws JavaModelException {
    final int indexOfStartOfClassData = CharOperation.indexOf(JavadocConstants.START_OF_CLASS_DATA,
            this.content, false);
    if (indexOfStartOfClassData == -1) {
        this.typeDocRange = UNKNOWN_FORMAT;
        return;/* w w w  .j a v a  2s  . c  om*/
    }
    int indexOfNextSeparator = CharOperation.indexOf(JavadocConstants.SEPARATOR_START, this.content, false,
            indexOfStartOfClassData);
    if (indexOfNextSeparator == -1) {
        this.typeDocRange = UNKNOWN_FORMAT;
        return;
    }
    int indexOfNextSummary = CharOperation.indexOf(JavadocConstants.NESTED_CLASS_SUMMARY, this.content, false,
            indexOfNextSeparator);
    if (indexOfNextSummary == -1 && this.type.isEnum()) {
        // try to find enum constant summary start
        indexOfNextSummary = CharOperation.indexOf(JavadocConstants.ENUM_CONSTANT_SUMMARY, this.content, false,
                indexOfNextSeparator);
    }
    if (indexOfNextSummary == -1 && this.type.isAnnotation()) {
        // try to find required enum constant summary start
        indexOfNextSummary = CharOperation.indexOf(JavadocConstants.ANNOTATION_TYPE_REQUIRED_MEMBER_SUMMARY,
                this.content, false, indexOfNextSeparator);
        if (indexOfNextSummary == -1) {
            // try to find optional enum constant summary start
            indexOfNextSummary = CharOperation.indexOf(JavadocConstants.ANNOTATION_TYPE_OPTIONAL_MEMBER_SUMMARY,
                    this.content, false, indexOfNextSeparator);
        }
    }
    if (indexOfNextSummary == -1) {
        // try to find field summary start
        indexOfNextSummary = CharOperation.indexOf(JavadocConstants.FIELD_SUMMARY, this.content, false,
                indexOfNextSeparator);
    }
    if (indexOfNextSummary == -1) {
        // try to find constructor summary start
        indexOfNextSummary = CharOperation.indexOf(JavadocConstants.CONSTRUCTOR_SUMMARY, this.content, false,
                indexOfNextSeparator);
    }
    if (indexOfNextSummary == -1) {
        // try to find method summary start
        indexOfNextSummary = CharOperation.indexOf(JavadocConstants.METHOD_SUMMARY, this.content, false,
                indexOfNextSeparator);
    }

    if (indexOfNextSummary == -1) {
        // we take the end of class data
        indexOfNextSummary = CharOperation.indexOf(JavadocConstants.END_OF_CLASS_DATA, this.content, false,
                indexOfNextSeparator);
    } else {
        // improve performance of computation of children ranges
        this.childrenStart = indexOfNextSummary + 1;
    }

    if (indexOfNextSummary == -1) {
        this.typeDocRange = UNKNOWN_FORMAT;
        return;
    }
    /*
     * Cut off the type hierarchy, see bug 119844.
     * We remove the contents between the start of class data and where
     * we guess the actual class comment starts.
     */
    int start = indexOfStartOfClassData + JavadocConstants.START_OF_CLASS_DATA_LENGTH;
    int indexOfFirstParagraph = CharOperation.indexOf(JavadocConstants.P.toCharArray(), this.content, false,
            start, indexOfNextSummary);
    int indexOfFirstDiv = CharOperation.indexOf(JavadocConstants.DIV_CLASS_BLOCK.toCharArray(), this.content,
            false, start, indexOfNextSummary);
    int afterHierarchy = indexOfNextSummary;
    if (indexOfFirstParagraph != -1 && indexOfFirstParagraph < afterHierarchy) {
        afterHierarchy = indexOfFirstParagraph;
    }
    if (indexOfFirstDiv != -1 && indexOfFirstDiv < afterHierarchy) {
        afterHierarchy = indexOfFirstDiv;
    }
    if (afterHierarchy != indexOfNextSummary) {
        start = afterHierarchy;
    }

    this.typeDocRange = new int[] { start, indexOfNextSummary };
}