本文整理匯總了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();
}
}