当前位置: 首页>>代码示例>>Java>>正文


Java ITextRegion.contains方法代码示例

本文整理汇总了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);
      }
    }
  }
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:24,代码来源:ImportsCollector.java

示例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);
  }
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:17,代码来源:AbstractTraceRegionToString.java

示例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;
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:40,代码来源:DefaultDocumentHighlightService.java

示例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);
          }
        }
      }
    }
  }
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:32,代码来源:ImportsCollector.java

示例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);
	}
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:15,代码来源:FormatterTester.java

示例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);
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:13,代码来源:AbstractTextSegment.java


注:本文中的org.eclipse.xtext.util.ITextRegion.contains方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。