本文整理汇总了Java中com.intellij.openapi.util.TextRange.getLength方法的典型用法代码示例。如果您正苦于以下问题:Java TextRange.getLength方法的具体用法?Java TextRange.getLength怎么用?Java TextRange.getLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.util.TextRange
的用法示例。
在下文中一共展示了TextRange.getLength方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fold
import com.intellij.openapi.util.TextRange; //导入方法依赖的package包/类
@Nullable
private FoldingDescriptor fold(@Nullable PsiElement element) {
if (element == null) {
return null;
}
TextRange textRange = element.getTextRange();
return textRange.getLength() > 5 ? new FoldingDescriptor(element, textRange) : null;
}
示例2: getOffsetInHost
import com.intellij.openapi.util.TextRange; //导入方法依赖的package包/类
@Override
public int getOffsetInHost(int offsetInDecoded, @NotNull TextRange rangeInsideHost) {
int result = offsetInDecoded < sourceOffsets.length ? sourceOffsets[offsetInDecoded] : -1;
if (result == -1) return -1;
return (result <= rangeInsideHost.getLength() ? result : rangeInsideHost.getLength()) + rangeInsideHost.getStartOffset();
}
示例3: processDirectives
import com.intellij.openapi.util.TextRange; //导入方法依赖的package包/类
private static void processDirectives(
@Nullable final BladePsiDirective baseDirective,
@NotNull final Queue<BladePsiDirective> directives,
@NotNull final Collection<FoldingDescriptor> foldingDescriptors,
@NotNull final Document document
) {
while (true) {
final BladePsiDirective directive = directives.peek();
if (directive == null) {
break;
}
if (IGNORED_DIRECTIVES.contains(directive.getName())) {
directives.poll();
continue;
}
if (baseDirective == null) {
if (!directive.isToBeClosed()) {
directives.poll();
continue;
}
processDirectives(directives.poll(), directives, foldingDescriptors, document);
continue;
}
// Eg. @endif or @elseif closes @if.
// Or that @elseif continues @if.
if (directive.closes(baseDirective) ||
directive.continues(baseDirective)) {
// Eg. @endif closes definitively an @if, @else or @elseif.
// But @elseif or @else don't have the same effect.
final boolean isDefinitivelyClosing = directive.isClosing() &&
!directive.isContinued();
final TextRange foldingRange = new TextRange(
baseDirective.getTextRange().getEndOffset(),
directive.getTextRange().getStartOffset() - calculateEndOffsetReductor(directive, isDefinitivelyClosing)
);
if ((foldingRange.getLength() > 0) &&
!StringUtils.strip(document.getText(foldingRange), " ").isEmpty()) {
foldingDescriptors.add(new FoldingDescriptor(baseDirective.getNode(), foldingRange, FoldingGroup.newGroup("Blade")));
}
if (isDefinitivelyClosing) {
directives.poll();
break;
}
processDirectives(directives.poll(), directives, foldingDescriptors, document);
break;
}
// Eg. @if or @elseif (but it will be catched on previous condition).
if (directive.isContinued()) {
processDirectives(directives.poll(), directives, foldingDescriptors, document);
continue;
}
directives.poll();
}
}