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


Java TextRange.getEndOffset方法代码示例

本文整理汇总了Java中com.intellij.openapi.util.TextRange.getEndOffset方法的典型用法代码示例。如果您正苦于以下问题:Java TextRange.getEndOffset方法的具体用法?Java TextRange.getEndOffset怎么用?Java TextRange.getEndOffset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.openapi.util.TextRange的用法示例。


在下文中一共展示了TextRange.getEndOffset方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: appendDescriptors

import com.intellij.openapi.util.TextRange; //导入方法依赖的package包/类
private void appendDescriptors(final ASTNode node, final Document document, final List<FoldingDescriptor> descriptors) {
    if (node.getElementType() == GCMTypes.CLASS_DECLARATION || node.getElementType() == GCMTypes.CUSTOM_TYPE_DECLARATION) {
        TextRange fullRange = node.getTextRange();
        if (fullRange.getEndOffset() - fullRange.getStartOffset() > 0) {

            try {
                int startOffset = fullRange.getStartOffset() + document.getText(fullRange).indexOf("{") + 1;
                int endOffset = fullRange.getEndOffset() - 1;
                if (startOffset < endOffset) {
                    TextRange shortRange = new TextRange(startOffset, fullRange.getEndOffset() - 1);
                    if (shortRange.getEndOffset() - shortRange.getStartOffset() > 1) {
                        descriptors.add(new FoldingDescriptor(node, shortRange));
                    }
                }
            } catch (Throwable e) {

            }
        }
    }
    ASTNode child = node.getFirstChildNode();
    while (child != null) {
        appendDescriptors(child, document, descriptors);
        child = child.getTreeNext();
    }
}
 
开发者ID:datathings,项目名称:greycat-idea-plugin,代码行数:26,代码来源:GCMFoldingBuilder.java

示例2: getRangeInElement

import com.intellij.openapi.util.TextRange; //导入方法依赖的package包/类
@Override
public TextRange getRangeInElement() {
  final TextRange textRange = getTextRange();

  AppleScriptReferenceElement[] appleScriptReferences = PsiTreeUtil.getChildrenOfType(this, AppleScriptReferenceElement.class);
  if (appleScriptReferences != null && appleScriptReferences.length > 0) {
    TextRange lastReferenceRange = appleScriptReferences[appleScriptReferences.length - 1].getTextRange();
    return new UnfairTextRange(
        lastReferenceRange.getStartOffset() - textRange.getStartOffset(),
        lastReferenceRange.getEndOffset() - textRange.getEndOffset()
    );
  }
  return new UnfairTextRange(0, textRange.getEndOffset() - textRange.getStartOffset());
}
 
开发者ID:ant-druha,项目名称:AppleScript-IDEA,代码行数:15,代码来源:AppleScriptReferenceElementImpl.java

示例3: getFoldRegionOfMethod

import com.intellij.openapi.util.TextRange; //导入方法依赖的package包/类
private Optional<FoldRegion> getFoldRegionOfMethod(Editor editor, PsiMethod psiMethod) {
	TextRange textRange = psiMethod.getTextRange();
	for (FoldRegion foldRegion : editor.getFoldingModel().getAllFoldRegions()) {
		if (textRange.getEndOffset() == foldRegion.getEndOffset()) {
			return Optional.of(foldRegion);
		}
	}
	return Optional.empty();
}
 
开发者ID:AWeinb,项目名称:IntellijMethodHierarchyHighlighter,代码行数:10,代码来源:MethodFolder.java

示例4: applyHighlight

import com.intellij.openapi.util.TextRange; //导入方法依赖的package包/类
@NotNull
private RangeHighlighter applyHighlight(Editor editor, TextAttributes attributes, PsiMethod psiMethod) {
	TextRange textRange = psiMethod.getTextRange();
	int start = textRange.getStartOffset();
	int end = textRange.getEndOffset();
	MarkupModel markupModel = editor.getMarkupModel();
	return markupModel.addRangeHighlighter(start, end, COLOR_Z_INDEX, attributes, TARGET_AREA);
}
 
开发者ID:AWeinb,项目名称:IntellijMethodHierarchyHighlighter,代码行数:9,代码来源:MethodBackgroundPainter.java

示例5: clearHighlights

import com.intellij.openapi.util.TextRange; //导入方法依赖的package包/类
private static void clearHighlights(Editor editor, HighlightManager highlightManager,
        List<TextRange> toRemoves) {
    if (editor instanceof EditorWindow) {
        editor = ((EditorWindow) editor).getDelegate();
    }
    
    RangeHighlighter[] highlighters =
            ((HighlightManagerImpl) highlightManager).getHighlighters(editor);
    
    Arrays.sort(highlighters, (o1, o2) -> o1.getStartOffset() - o2.getStartOffset());
    Collections.sort(toRemoves, (o1, o2) -> o1.getStartOffset() - o2.getStartOffset());
    
    int i = 0;
    int j = 0;
    while (i < highlighters.length && j < toRemoves.size()) {
        RangeHighlighter highlighter = highlighters[i];
        final TextAttributes ta = highlighter.getTextAttributes();
        final TextRange textRange = TextRange.create(highlighter);
        final TextRange toRemove = toRemoves.get(j);
        if (ta != null && ta instanceof NamedTextAttr // wrap
                && highlighter.getLayer() == HighlighterLayer.SELECTION - 1 // wrap
                && toRemove.equals(textRange)) {
            highlightManager.removeSegmentHighlighter(editor, highlighter);
            i++;
        } else if (toRemove.getStartOffset() > textRange.getEndOffset()) {
            i++;
        } else if (toRemove.getEndOffset() < textRange.getStartOffset()) {
            j++;
        } else {
            i++;
            j++;
        }
    }
}
 
开发者ID:huoguangjin,项目名称:MultiHighlight,代码行数:35,代码来源:MultiHighlightHandler.java


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