本文整理汇总了Java中org.eclipse.xtext.util.ITextRegion.contains方法的典型用法代码示例。如果您正苦于以下问题:Java ITextRegion.contains方法的具体用法?Java ITextRegion.contains怎么用?Java ITextRegion.contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.xtext.util.ITextRegion
的用法示例。
在下文中一共展示了ITextRegion.contains方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: collectImports
import org.eclipse.xtext.util.ITextRegion; //导入方法依赖的package包/类
/**
* Collects import declarations in XtextResource for the given range (selectedRegion)
*/
public void collectImports(final XtextResource state, final ITextRegion selectedRegion, final ImportsAcceptor acceptor) {
ICompositeNode rootNode = state.getParseResult().getRootNode();
final EObject selectedSemanticObj = this.findActualSemanticObjectFor(rootNode, selectedRegion);
final Iterable<ILeafNode> contentsIterator = NodeModelUtils.findActualNodeFor(selectedSemanticObj).getLeafNodes();
for (final ILeafNode node : contentsIterator) {
{
final ITextRegion nodeRegion = node.getTotalTextRegion();
boolean _contains = selectedRegion.contains(nodeRegion);
if (_contains) {
final EObject semanticElement = node.getSemanticElement();
if ((semanticElement != null)) {
this.visit(semanticElement, NodeModelUtils.findActualNodeFor(semanticElement), acceptor);
}
}
if ((node.isHidden() && this.grammarAccess.getML_COMMENTRule().equals(node.getGrammarElement()))) {
this.addJavaDocReferences(node, selectedRegion, acceptor);
}
}
}
}
示例2: shouldInclude
import org.eclipse.xtext.util.ITextRegion; //导入方法依赖的package包/类
protected boolean shouldInclude(final AbstractTraceRegion region, final ILocationData location) {
SourceRelativeURI _elvis = null;
SourceRelativeURI _srcRelativePath = location.getSrcRelativePath();
if (_srcRelativePath != null) {
_elvis = _srcRelativePath;
} else {
SourceRelativeURI _associatedSrcRelativePath = region.getAssociatedSrcRelativePath();
_elvis = _associatedSrcRelativePath;
}
final ITextRegion frame = this.getRemoteFrame(_elvis);
if ((frame == null)) {
return true;
} else {
return frame.contains(location);
}
}
示例3: isDocumentHighlightAvailableFor
import org.eclipse.xtext.util.ITextRegion; //导入方法依赖的package包/类
/**
* Returns with {@code true} if the AST element selected from the resource
* can provide document highlights, otherwise returns with {@code false}.
*
* <p>
* Clients may override this method to change the default behavior.
*
* @param selectedElemnt
* the selected element resolved via the offset from the
* resource. Can be {@code null}.
* @param resource
* the resource for the document.
* @param offset
* the offset of the selection.
*
* @return {@code true} if the document highlight is available for the
* selected element, otherwise {@code false}.
*
*/
protected boolean isDocumentHighlightAvailableFor(final EObject selectedElemnt, final XtextResource resource,
final int offset) {
if (selectedElemnt == null || !getSelectedElementFilter().apply(selectedElemnt)) {
return false;
}
final EObject containedElement = offsetHelper.resolveContainedElementAt(resource, offset);
// Special handling to avoid such cases when the selection is not
// exactly on the desired element.
if (selectedElemnt == containedElement) {
final ITextRegion region = locationInFileProvider.getSignificantTextRegion(containedElement);
return !isNullOrEmpty(region)
// Region is comparable to a selection in an editor,
// therefore the end position is exclusive.
&& (region.contains(offset) || (region.getOffset() + region.getLength()) == offset);
}
return true;
}
示例4: addJavaDocReferences
import org.eclipse.xtext.util.ITextRegion; //导入方法依赖的package包/类
private void addJavaDocReferences(final INode documentationNode, final ITextRegion selectedRegion, final ImportsAcceptor acceptor) {
List<ReplaceRegion> _computeTypeRefRegions = this.javaDocTypeReferenceProvider.computeTypeRefRegions(documentationNode);
for (final ReplaceRegion docTypeReference : _computeTypeRefRegions) {
{
int _offset = docTypeReference.getOffset();
int _length = docTypeReference.getLength();
final TextRegion referenceRange = new TextRegion(_offset, _length);
boolean _contains = selectedRegion.contains(referenceRange);
if (_contains) {
String docTypeText = docTypeReference.getText();
final EObject element = NodeModelUtils.findActualSemanticObjectFor(documentationNode);
IScope scope = this.scopeProvider.getScope(element,
TypesPackage.Literals.JVM_PARAMETERIZED_TYPE_REFERENCE__TYPE);
IEObjectDescription singleElement = scope.getSingleElement(QualifiedName.create(docTypeText));
JvmType referencedType = null;
if ((singleElement != null)) {
EObject _eObjectOrProxy = singleElement.getEObjectOrProxy();
referencedType = ((JvmType) _eObjectOrProxy);
}
if (((referencedType instanceof JvmDeclaredType) && (!referencedType.eIsProxy()))) {
JvmDeclaredType casted = ((JvmDeclaredType) referencedType);
boolean _equals = casted.getQualifiedName().equals(docTypeText);
boolean _not = (!_equals);
if (_not) {
acceptor.acceptTypeImport(casted);
}
}
}
}
}
}
示例5: assertReplacementsAreInRegion
import org.eclipse.xtext.util.ITextRegion; //导入方法依赖的package包/类
protected void assertReplacementsAreInRegion(List<ITextReplacement> rep, Collection<ITextRegion> regions,
String doc) {
Set<ITextReplacement> invalid = Sets.newHashSet();
ALLOWED: for (ITextRegion allowed : regions)
for (ITextReplacement r : rep) {
if (allowed.contains(r))
continue ALLOWED;
invalid.add(r);
}
if (!invalid.isEmpty()) {
String visualized = new TextRegionsToString().addAllReplacements(invalid).toString();
fail("One or more TextReplacements are outside of the allowed region. Region: " + regions, visualized);
}
}
示例6: merge
import org.eclipse.xtext.util.ITextRegion; //导入方法依赖的package包/类
@Override
public ITextSegment merge(ITextRegion other) {
if (contains(other))
return this;
if (other instanceof ITextSegment && other.contains(this))
return (ITextSegment) other;
int offset = getOffset();
int length = getLength();
int newOffset = Math.min(offset, other.getOffset());
int newLength = Math.max(offset + length, other.getOffset() + other.getLength()) - newOffset;
return new TextSegment(getTextRegionAccess(), newOffset, newLength);
}