• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java FoldingBuilder类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.intellij.lang.folding.FoldingBuilder的典型用法代码示例。如果您正苦于以下问题:Java FoldingBuilder类的具体用法?Java FoldingBuilder怎么用?Java FoldingBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



FoldingBuilder类属于com.intellij.lang.folding包,在下文中一共展示了FoldingBuilder类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: buildRanges

import com.intellij.lang.folding.FoldingBuilder; //导入依赖的package包/类
@NotNull
private static Map<PsiElement, FoldingDescriptor> buildRanges(@NotNull Editor editor, @NotNull PsiFile psiFile) {
  final FoldingBuilder foldingBuilder = LanguageFolding.INSTANCE.forLanguage(psiFile.getLanguage());
  final ASTNode node = psiFile.getNode();
  if (node == null) return Collections.emptyMap();
  final FoldingDescriptor[] descriptors = LanguageFolding.buildFoldingDescriptors(foldingBuilder, psiFile, editor.getDocument(), true);
  Map<PsiElement, FoldingDescriptor> ranges = new HashMap<PsiElement, FoldingDescriptor>();
  for (FoldingDescriptor descriptor : descriptors) {
    final ASTNode ast = descriptor.getElement();
    final PsiElement psi = ast.getPsi();
    if (psi != null) {
      ranges.put(psi, descriptor);
    }
  }
  return ranges;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:DocumentFoldingInfo.java


示例2: getFoldingsFor

import com.intellij.lang.folding.FoldingBuilder; //导入依赖的package包/类
private static void getFoldingsFor(@NotNull PsiFile file,
                                   @NotNull Document document,
                                   @NotNull FoldingMap elementsToFoldMap,
                                   boolean quick) {
  final FileViewProvider viewProvider = file.getViewProvider();
  TextRange docRange = TextRange.from(0, document.getTextLength());
  for (final Language language : viewProvider.getLanguages()) {
    final PsiFile psi = viewProvider.getPsi(language);
    final FoldingBuilder foldingBuilder = LanguageFolding.INSTANCE.forLanguage(language);
    if (psi != null && foldingBuilder != null) {
      for (FoldingDescriptor descriptor : LanguageFolding.buildFoldingDescriptors(foldingBuilder, psi, document, quick)) {
        TextRange range = descriptor.getRange();
        if (!docRange.contains(range)) {
          LOG.error("Folding descriptor " + descriptor +
                    " made by " + foldingBuilder +
                    " for " +language +
                    " and called on file " + psi +
                    " is outside document range: " + docRange);
        }
        elementsToFoldMap.putValue(descriptor.getElement().getPsi(), descriptor);
      }
    }
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:25,代码来源:FoldingUpdate.java


示例3: buildRanges

import com.intellij.lang.folding.FoldingBuilder; //导入依赖的package包/类
@Nonnull
private static Map<PsiElement, FoldingDescriptor> buildRanges(@Nonnull Editor editor, @Nonnull PsiFile psiFile) {
  final FoldingBuilder foldingBuilder = LanguageFolding.INSTANCE.forLanguage(psiFile.getLanguage());
  final ASTNode node = psiFile.getNode();
  if (node == null) return Collections.emptyMap();
  final FoldingDescriptor[] descriptors = LanguageFolding.buildFoldingDescriptors(foldingBuilder, psiFile, editor.getDocument(), true);
  Map<PsiElement, FoldingDescriptor> ranges = new HashMap<>();
  for (FoldingDescriptor descriptor : descriptors) {
    final ASTNode ast = descriptor.getElement();
    final PsiElement psi = ast.getPsi();
    if (psi != null) {
      ranges.put(psi, descriptor);
    }
  }
  return ranges;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:17,代码来源:DocumentFoldingInfo.java


示例4: getFoldingsFor

import com.intellij.lang.folding.FoldingBuilder; //导入依赖的package包/类
private static void getFoldingsFor(@Nonnull PsiFile file,
                                   @Nonnull Document document,
                                   @Nonnull List<RegionInfo> elementsToFold,
                                   boolean quick) {
  final FileViewProvider viewProvider = file.getViewProvider();
  TextRange docRange = TextRange.from(0, document.getTextLength());
  for (final Language language : viewProvider.getLanguages()) {
    final PsiFile psi = viewProvider.getPsi(language);
    final FoldingBuilder foldingBuilder = LanguageFolding.INSTANCE.forLanguage(language);
    if (psi != null && foldingBuilder != null) {
      for (FoldingDescriptor descriptor : LanguageFolding.buildFoldingDescriptors(foldingBuilder, psi, document, quick)) {
        PsiElement psiElement = descriptor.getElement().getPsi();
        if (psiElement == null) {
          LOG.error("No PSI for folding descriptor " + descriptor);
          continue;
        }
        if (!docRange.contains(descriptor.getRange())) {
          diagnoseIncorrectRange(psi, document, language, foldingBuilder, descriptor, psiElement);
          continue;
        }
        RegionInfo regionInfo = new RegionInfo(descriptor, psiElement);
        elementsToFold.add(regionInfo);
      }
    }
  }
}
 
开发者ID:consulo,项目名称:consulo,代码行数:27,代码来源:FoldingUpdate.java


示例5: supportsDumbModeFolding

import com.intellij.lang.folding.FoldingBuilder; //导入依赖的package包/类
/**
 * Checks the ability to initialize folding in the Dumb Mode for file.
 *
 * @param file the file to test
 * @return true  if folding initialization available in the Dumb Mode
 */
public static boolean supportsDumbModeFolding(@NotNull PsiFile file) {
  final FileViewProvider viewProvider = file.getViewProvider();
  for (final Language language : viewProvider.getLanguages()) {
    final FoldingBuilder foldingBuilder = LanguageFolding.INSTANCE.forLanguage(language);
    if(foldingBuilder != null && !DumbService.isDumbAware(foldingBuilder))
      return false;
  }
  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:FoldingUpdate.java


示例6: getFoldingsFor

import com.intellij.lang.folding.FoldingBuilder; //导入依赖的package包/类
private static void getFoldingsFor(@NotNull PsiFile file,
                                   @NotNull Document document,
                                   @NotNull FoldingMap elementsToFoldMap,
                                   boolean quick) {
  final FileViewProvider viewProvider = file.getViewProvider();
  TextRange docRange = TextRange.from(0, document.getTextLength());
  for (final Language language : viewProvider.getLanguages()) {
    final PsiFile psi = viewProvider.getPsi(language);
    final FoldingBuilder foldingBuilder = LanguageFolding.INSTANCE.forLanguage(language);
    if (psi != null && foldingBuilder != null) {
      for (FoldingDescriptor descriptor : LanguageFolding.buildFoldingDescriptors(foldingBuilder, psi, document, quick)) {
        TextRange range = descriptor.getRange();
        ASTNode element = descriptor.getElement();
        PsiElement psiElement = element.getPsi();
        if (!docRange.contains(range)) {
          PsiDocumentManager psiDocumentManager = PsiDocumentManager.getInstance(file.getProject());
          LOG.error("Folding descriptor " + descriptor +
                    " made by " + foldingBuilder +
                    " for " + language +
                    " and called on file " + psi +
                    " is outside document range: " + docRange +
                    ", document committed: " + psiDocumentManager.isCommitted(document) +
                    ", element range: " + element.getTextRange() +
                    ", PSI element: " + psiElement +
                    ", PSI element range: " + (psiElement == null ? null : psiElement.getTextRange()) +
                    ", PSI element is valid: " + (psiElement != null && psiElement.isValid()) +
                    ", PSI file is valid: " + file.isValid() +
                    ", PSI file range: " + file.getTextRange() +
                    ", PSI file corresponds to document: " + (file == psiDocumentManager.getCachedPsiFile(document)),
                    ApplicationManager.getApplication().isInternal()
                    ? new Attachment[] {AttachmentFactory.createAttachment(document), new Attachment("psiTree.txt", DebugUtil.psiToString(psi, false, true))}
                    : new Attachment[0]);
        }
        elementsToFoldMap.putValue(psiElement, descriptor);
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:39,代码来源:FoldingUpdate.java


示例7: doAddForChildren

import com.intellij.lang.folding.FoldingBuilder; //导入依赖的package包/类
protected void doAddForChildren(final XmlElement tag, final List<FoldingDescriptor> foldings, final Document document) {
  final PsiElement[] children = tag.getChildren();

  for (PsiElement child : children) {
    ProgressManager.checkCanceled();

    if (child instanceof XmlTag || child instanceof XmlConditionalSection) {
      addElementsToFold(foldings, (XmlElement)child, document);
    }
    else if (child instanceof XmlComment) {
      addToFold(foldings, child, document);
    }
    else if (child instanceof XmlText || child instanceof XmlProlog) {
      final PsiElement[] grandChildren = child.getChildren();

      for (PsiElement grandChild : grandChildren) {
        ProgressManager.checkCanceled();

        if (grandChild instanceof XmlComment) {
          addToFold(foldings, grandChild, document);
        }
      }
    }
    else if(child instanceof XmlAttribute && isAttributeShouldBeFolded((XmlAttribute)child)) {
      addToFold(foldings, child, document);
    }
    else {
      final Language language = child.getLanguage();
      if (!(language instanceof XMLLanguage) && language != Language.ANY) {
        final FoldingBuilder foldingBuilder = LanguageFolding.INSTANCE.forLanguage(language);

        if (foldingBuilder != null) {
          final FoldingDescriptor[] foldingDescriptors = foldingBuilder.buildFoldRegions(child.getNode(), document);

          ContainerUtil.addAll(foldings, foldingDescriptors);
        }
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:41,代码来源:XmlCodeFoldingBuilder.java


示例8: supportsDumbModeFolding

import com.intellij.lang.folding.FoldingBuilder; //导入依赖的package包/类
/**
 * Checks the ability to initialize folding in the Dumb Mode for file.
 *
 * @param file the file to test
 * @return true  if folding initialization available in the Dumb Mode
 */
static boolean supportsDumbModeFolding(@Nonnull PsiFile file) {
  final FileViewProvider viewProvider = file.getViewProvider();
  for (final Language language : viewProvider.getLanguages()) {
    final FoldingBuilder foldingBuilder = LanguageFolding.INSTANCE.forLanguage(language);
    if(foldingBuilder != null && !DumbService.isDumbAware(foldingBuilder))
      return false;
  }
  return true;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:16,代码来源:FoldingUpdate.java


示例9: diagnoseIncorrectRange

import com.intellij.lang.folding.FoldingBuilder; //导入依赖的package包/类
private static void diagnoseIncorrectRange(@Nonnull PsiFile file,
                                           @Nonnull Document document,
                                           Language language,
                                           FoldingBuilder foldingBuilder, FoldingDescriptor descriptor, PsiElement psiElement) {
  String message = "Folding descriptor " + descriptor +
                   " made by " + foldingBuilder +
                   " for " + language +
                   " is outside document range" +
                   ", PSI element: " + psiElement +
                   ", PSI element range: " + psiElement.getTextRange() + "; " + DebugUtil.diagnosePsiDocumentInconsistency(psiElement, document);
  LOG.error(message, ApplicationManager.getApplication().isInternal()
                     ? new Attachment[]{AttachmentFactory.createAttachment(document), new Attachment("psiTree.txt", DebugUtil.psiToString(file, false, true))}
                     : Attachment.EMPTY_ARRAY);
}
 
开发者ID:consulo,项目名称:consulo,代码行数:15,代码来源:FoldingUpdate.java


示例10: isCollapseByDefault

import com.intellij.lang.folding.FoldingBuilder; //导入依赖的package包/类
public static boolean isCollapseByDefault(PsiElement element) {
  final Language lang = element.getLanguage();
  final FoldingBuilder foldingBuilder = LanguageFolding.INSTANCE.forLanguage(lang);
  return foldingBuilder != null && foldingBuilder.isCollapsedByDefault(element.getNode());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:6,代码来源:FoldingPolicy.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java CertificateFactorySpi类代码示例发布时间:2022-05-21
下一篇:
Java MimeTypesUtil类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap