本文整理汇总了Java中org.eclipse.xtext.util.ITextRegion.EMPTY_REGION属性的典型用法代码示例。如果您正苦于以下问题:Java ITextRegion.EMPTY_REGION属性的具体用法?Java ITextRegion.EMPTY_REGION怎么用?Java ITextRegion.EMPTY_REGION使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.eclipse.xtext.util.ITextRegion
的用法示例。
在下文中一共展示了ITextRegion.EMPTY_REGION属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createLocationData
private static ILocationData createLocationData(ITraceURIConverter converter, ILocationInFileProvider locationProvider, EObject object, ILocationInFileProviderExtension.RegionDescription query, boolean skipEmpty) {
ITextRegion textRegion = locationProvider instanceof ILocationInFileProviderExtension ?
((ILocationInFileProviderExtension) locationProvider).getTextRegion(object, query) : locationProvider.getFullTextRegion(object);
if (!(textRegion instanceof ITextRegionWithLineInformation)) {
if (log.isDebugEnabled())
log.debug("location provider returned text region without line information.", new Exception());
if (textRegion != null)
textRegion = new TextRegionWithLineInformation(textRegion.getOffset(), textRegion.getLength(), 0, 0);
else
return null;
}
// usually we want to skip empty regions but if the root region is empty, we want to use it to store the path information along
// with the empty offset / length pair
if (skipEmpty && textRegion == ITextRegion.EMPTY_REGION) {
return null;
}
ILocationData newData = createLocationData(converter, object, (ITextRegionWithLineInformation) textRegion);
return newData;
}
示例2: traceSignificant
public ITreeAppendable traceSignificant(final ITreeAppendable appendable, final EObject source, final boolean useForDebugging) {
ITreeAppendable _xifexpression = null;
if ((appendable instanceof TreeAppendable)) {
_xifexpression = ((TreeAppendable)appendable).trace(source, ILocationInFileProviderExtension.RegionDescription.SIGNIFICANT, useForDebugging);
} else {
ITreeAppendable _xblockexpression = null;
{
ITextRegion _significantTextRegion = this.locationProvider.getSignificantTextRegion(source);
final ITextRegionWithLineInformation it = ((ITextRegionWithLineInformation) _significantTextRegion);
ITreeAppendable _xifexpression_1 = null;
if (((it != null) && (it != ITextRegion.EMPTY_REGION))) {
int _offset = it.getOffset();
int _length = it.getLength();
int _lineNumber = it.getLineNumber();
int _endLineNumber = it.getEndLineNumber();
LocationData _locationData = new LocationData(_offset, _length, _lineNumber, _endLineNumber, null);
_xifexpression_1 = appendable.trace(_locationData, useForDebugging);
} else {
_xifexpression_1 = appendable;
}
_xblockexpression = _xifexpression_1;
}
_xifexpression = _xblockexpression;
}
return _xifexpression;
}
示例3: createRegion
/**
* @since 2.3
*/
protected ITextRegion createRegion(List<INode> nodes, RegionDescription query) {
if (query == RegionDescription.FULL || query == RegionDescription.SIGNIFICANT)
return createRegion(nodes);
ITextRegion result = ITextRegion.EMPTY_REGION;
for (INode node : nodes) {
for(INode leafNode: node.getLeafNodes()) {
if (!isHidden(leafNode, query)) {
ITextRegionWithLineInformation region = leafNode.getTextRegionWithLineInformation();
if (region.getLength() != 0) {
result = result.merge(toZeroBasedRegion(region));
}
}
}
}
return result;
}
示例4: serializeSubtree
@Override
public TreeConstructionReport serializeSubtree(EObject object, ITokenStream out) throws IOException {
TreeConstructionReportImpl report = createReport(object);
AbstractToken root = serialize(object, report);
Set<ICompositeNode> roots = Sets.newHashSet();
Map<EObject, AbstractToken> obj2token = Maps.newHashMap();
collectRootsAndEObjects(root, obj2token, roots);
// dump("", root);
Map<ILeafNode, EObject> comments = commentAssociater.associateCommentsWithSemanticEObjects(object, roots);
for (ICompositeNode r : roots)
assignNodesByMatching(obj2token, r, comments);
WsMergerStream wsout = new WsMergerStream(out);
// dump("", root);
// System.out.println(EmfFormatter.objToStr(roots.iterator().next(),
// ParsetreePackage.Literals.ABSTRACT_NODE__TOTAL_LENGTH,
// ParsetreePackage.Literals.ABSTRACT_NODE__TOTAL_OFFSET,
// ParsetreePackage.Literals.ABSTRACT_NODE__TOTAL_LINE, ParsetreePackage.Literals.ABSTRACT_NODE__PARENT));
ITextRegion previousLocation = ITextRegion.EMPTY_REGION;
initStream(root, wsout);
previousLocation = write(root, wsout, previousLocation);
wsout.flush();
report.setPreviousLocation(previousLocation);
return report;
}
示例5: trace
@Override
public ITreeAppendable trace(EObject object, EStructuralFeature feature, int indexInList) {
ITextRegion textRegion = locationProvider.getFullTextRegion(object, feature, indexInList);
if (!(textRegion instanceof ITextRegionWithLineInformation)) {
if (log.isDebugEnabled())
log.debug("location provider returned text region without line information. Synthesized dummy data.", new Exception());
textRegion = new TextRegionWithLineInformation(textRegion.getOffset(), textRegion.getLength(), 0, 0);
}
if (textRegion == ITextRegion.EMPTY_REGION) {
return this;
}
ILocationData newData = createLocationData(traceURIConverter, object, (ITextRegionWithLineInformation) textRegion);
return trace(Collections.singleton(newData), false);
}
示例6: traceWithComments
public ITreeAppendable traceWithComments(final ITreeAppendable appendable, final EObject source) {
ITreeAppendable _xifexpression = null;
if ((appendable instanceof TreeAppendable)) {
_xifexpression = ((TreeAppendable)appendable).trace(source, ILocationInFileProviderExtension.RegionDescription.INCLUDING_COMMENTS, false);
} else {
ITreeAppendable _xblockexpression = null;
{
ITextRegion _switchResult = null;
final ILocationInFileProvider locationProvider = this.locationProvider;
boolean _matched = false;
if (locationProvider instanceof ILocationInFileProviderExtension) {
_matched=true;
_switchResult = ((ILocationInFileProviderExtension)this.locationProvider).getTextRegion(source, ILocationInFileProviderExtension.RegionDescription.INCLUDING_COMMENTS);
}
if (!_matched) {
_switchResult = this.locationProvider.getFullTextRegion(source);
}
final ITextRegionWithLineInformation it = ((ITextRegionWithLineInformation) _switchResult);
ITreeAppendable _xifexpression_1 = null;
if (((it != null) && (it != ITextRegion.EMPTY_REGION))) {
int _offset = it.getOffset();
int _length = it.getLength();
int _lineNumber = it.getLineNumber();
int _endLineNumber = it.getEndLineNumber();
LocationData _locationData = new LocationData(_offset, _length, _lineNumber, _endLineNumber, null);
_xifexpression_1 = appendable.trace(_locationData);
} else {
_xifexpression_1 = appendable;
}
_xblockexpression = _xifexpression_1;
}
_xifexpression = _xblockexpression;
}
return _xifexpression;
}
示例7: doGetTextRegion
/**
* @since 2.3
*/
protected ITextRegion doGetTextRegion(EObject obj, /* @NonNull */ RegionDescription query) {
ICompositeNode node = findNodeFor(obj);
if (node == null) {
if (obj.eContainer() == null)
return ITextRegion.EMPTY_REGION;
return getTextRegion(obj.eContainer(), query);
}
List<INode> nodes = null;
if (query == RegionDescription.SIGNIFICANT)
nodes = getLocationNodes(obj);
if (nodes == null || nodes.isEmpty())
nodes = Collections.<INode>singletonList(node);
return createRegion(nodes, query);
}