Example usage for org.eclipse.jdt.core.compiler ITerminalSymbols TokenNameRBRACE

List of usage examples for org.eclipse.jdt.core.compiler ITerminalSymbols TokenNameRBRACE

Introduction

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

Prototype

int TokenNameRBRACE

To view the source code for org.eclipse.jdt.core.compiler ITerminalSymbols TokenNameRBRACE.

Click Source Link

Usage

From source file:com.cb.eclipse.folding.java.calculation.AbstractBlockStrategy.java

License:Open Source License

/**
 * Push left braces, pop right braces and calculate the distance in between
 * as a region./*from   w  ww .  jav a2  s.  c o m*/
 * 
 * @see com.cb.eclipse.folding.java.calculation.RegionCalculationStrategy#handle(int,
 *      int, int, org.eclipse.jdt.core.IJavaElement)
 */
public void handle(int token, int start, int end, IJavaElement owner) throws JavaModelException {

    boolean collapseComments = FoldingPlugin.getPrefs().getBoolean(PreferenceKeys.COLLAPSE_COMMENT_BLOCKS);
    boolean collapseJavadoc = FoldingPlugin.getPrefs().getBoolean(PreferenceKeys.COLLAPSE_JAVADOCS);

    switch (token) {

    case ITerminalSymbols.TokenNameLBRACE: {
        pushBrace(start);
        helper.end();
        break;
    }
    case ITerminalSymbols.TokenNameRBRACE: {
        if (hasUsablePeer()) {

            int oldStart = popBrace();
            helper.end();
            if (shouldFold(owner, token)) {
                boolean doCollapse = shouldCollapse(owner, token);
                boolean shouldNegate = shouldFilterLastLine(owner, token);
                addRegion(new EnhancedPosition(oldStart, end - oldStart,
                        new JavaPositionMetadata(false, shouldNegate, doCollapse, true, getClass().getName())));
            }
        } else {
            System.out.println("Bad brace found... omitting!");
        }

        break;
    }

    default: {
        if (digestComments)
            helper.handle(token, start, end, owner);

    }

    }

}