Example usage for org.antlr.v4.runtime.misc IntervalSet size

List of usage examples for org.antlr.v4.runtime.misc IntervalSet size

Introduction

In this page you can find the example usage for org.antlr.v4.runtime.misc IntervalSet size.

Prototype

@Override
    public int size() 

Source Link

Usage

From source file:org.tvl.goworks.editor.go.highlighter.GoHighlighterLexer.java

License:Open Source License

private static Transition patchTransition(Transition transition, IntervalSet digitChars,
        IntervalSet letterChars) {//from  ww w. jav  a 2  s. co m
    switch (transition.getSerializationType()) {
    case Transition.ATOM:
    case Transition.RANGE:
    case Transition.SET:
        break;

    default:
        return null;
    }

    IntervalSet label = transition.label();
    if (label == null) {
        return null;
    }

    IntervalSet updated = null;
    if (label.contains(unicodeDigitPlaceholder)) {
        updated = new IntervalSet(label);
        updated.addAll(digitChars);
        if (updated.size() == digitChars.size()) {
            updated = digitChars;
        }
    }

    if (label.contains(unicodeLetterPlaceholder)) {
        if (updated != null) {
            updated.addAll(label);
        } else {
            updated = new IntervalSet(label);
        }

        updated.addAll(letterChars);
        if (updated.size() == letterChars.size()) {
            updated = letterChars;
        }
    }

    if (updated == null) {
        return null;
    }

    return new SetTransition(transition.target, updated);
}