本文整理汇总了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();
}
}
示例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());
}
示例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();
}
示例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);
}
示例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++;
}
}
}