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