Search in sources :

Example 1 with ElementPattern

use of org.eclipse.xtext.formatting.impl.AbstractFormattingConfig.ElementPattern in project xtext-core by eclipse.

the class FormattingConfigBasedStream method collectLocators.

protected Set<ElementLocator> collectLocators(EObject ele) {
    Set<ElementLocator> result = Sets.newHashSet(activeRangeLocators);
    Collection<ElementLocator> loc = Sets.newHashSet();
    if (ele instanceof AbstractElement)
        for (ElementPattern pattern : matcher.matchNext((AbstractElement) ele)) loc.add(pattern.getLocator());
    if ((last instanceof AbstractRule && hiddenTokenHelper.isComment((AbstractRule) last)) || (ele instanceof AbstractRule && hiddenTokenHelper.isComment((AbstractRule) ele)))
        loc = collectLocatorsForComments(loc, last, ele);
    last = ele;
    for (ElementLocator locator : loc) if (locator.getType() == LocatorType.RANGE && !activeRangeLocators.add(locator))
        activeRangeLocators.remove(locator);
    result.addAll(loc);
    for (ElementLocator locator : result) {
        if (locator instanceof IndentationLocatorStart)
            indentationLevel++;
        else if (locator instanceof IndentationLocatorEnd)
            indentationLevel--;
    }
    return result;
}
Also used : AbstractElement(org.eclipse.xtext.AbstractElement) ElementLocator(org.eclipse.xtext.formatting.impl.AbstractFormattingConfig.ElementLocator) ElementPattern(org.eclipse.xtext.formatting.impl.AbstractFormattingConfig.ElementPattern) AbstractRule(org.eclipse.xtext.AbstractRule) IndentationLocatorStart(org.eclipse.xtext.formatting.impl.FormattingConfig.IndentationLocatorStart) IndentationLocatorEnd(org.eclipse.xtext.formatting.impl.FormattingConfig.IndentationLocatorEnd)

Aggregations

AbstractElement (org.eclipse.xtext.AbstractElement)1 AbstractRule (org.eclipse.xtext.AbstractRule)1 ElementLocator (org.eclipse.xtext.formatting.impl.AbstractFormattingConfig.ElementLocator)1 ElementPattern (org.eclipse.xtext.formatting.impl.AbstractFormattingConfig.ElementPattern)1 IndentationLocatorEnd (org.eclipse.xtext.formatting.impl.FormattingConfig.IndentationLocatorEnd)1 IndentationLocatorStart (org.eclipse.xtext.formatting.impl.FormattingConfig.IndentationLocatorStart)1