use of org.eclipse.xtext.formatting2.regionaccess.IEObjectRegion in project xtext-core by eclipse.
the class FormattableDocument method append.
@Override
public <T extends EObject> T append(T owner, Procedure1<? super IHiddenRegionFormatter> after) {
if (owner != null) {
IEObjectRegion region = getTextRegionAccess().regionForEObject(owner);
if (region != null) {
IHiddenRegion gap = region.getNextHiddenRegion();
set(gap, after);
}
}
return owner;
}
use of org.eclipse.xtext.formatting2.regionaccess.IEObjectRegion in project xtext-core by eclipse.
the class TextRegionAccessToString method toString.
@Override
public String toString() {
List<ITextSegment> list = toTokenAndGapList();
if (list.isEmpty())
return "(empty)";
ITextRegionAccess access = list.get(0).getTextRegionAccess();
DiffColumn diff = new DiffColumn(access);
TextRegionListToString result = new TextRegionListToString();
if (!hideColumnExplanation) {
if (diff.isDiff()) {
result.add("Columns: 1:offset 2:length 3:diff 4:kind 5: text 6:grammarElement", false);
} else {
result.add("Columns: 1:offset 2:length 3:kind 4: text 5:grammarElement", false);
}
result.add("Kind: H=IHiddenRegion S=ISemanticRegion B/E=IEObjectRegion", false);
result.add("", false);
}
appendRegions(result, list, diff, false);
diff.appendDiffs(result, this);
return result.toString();
}
use of org.eclipse.xtext.formatting2.regionaccess.IEObjectRegion in project xtext-core by eclipse.
the class FormattableDocument method interior.
@Override
public <T extends EObject> T interior(T object, Procedure1<? super IHiddenRegionFormatter> init) {
if (object != null) {
IEObjectRegion objRegion = getTextRegionAccess().regionForEObject(object);
if (objRegion != null) {
IHiddenRegion previous = objRegion.getPreviousHiddenRegion();
IHiddenRegion next = objRegion.getNextHiddenRegion();
if (previous != null && next != null && previous != next) {
interior(previous.getNextSemanticRegion(), next.getPreviousSemanticRegion(), init);
}
}
}
return object;
}
use of org.eclipse.xtext.formatting2.regionaccess.IEObjectRegion in project xtext-core by eclipse.
the class FormattableDocument method prepend.
@Override
public <T extends EObject> T prepend(T owner, Procedure1<? super IHiddenRegionFormatter> before) {
if (owner != null) {
IEObjectRegion region = getTextRegionAccess().regionForEObject(owner);
if (region != null) {
IHiddenRegion gap = region.getPreviousHiddenRegion();
set(gap, before);
}
}
return owner;
}
use of org.eclipse.xtext.formatting2.regionaccess.IEObjectRegion in project xtext-core by eclipse.
the class FormattableDocument method surround.
@Override
public <T extends EObject> T surround(T owner, Procedure1<? super IHiddenRegionFormatter> beforeAndAfter) {
if (owner != null && !owner.eIsProxy()) {
IEObjectRegion region = getTextRegionAccess().regionForEObject(owner);
if (region == null)
return owner;
IHiddenRegion previous = region.getPreviousHiddenRegion();
IHiddenRegion next = region.getNextHiddenRegion();
set(previous, next, beforeAndAfter);
}
return owner;
}
Aggregations