当前位置: 首页>>代码示例>>Java>>正文


Java FoldingDescriptor类代码示例

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


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

示例1: buildFoldRegions

import com.intellij.lang.folding.FoldingDescriptor; //导入依赖的package包/类
@NotNull
@Override
public FoldingDescriptor[] buildFoldRegions(@NotNull PsiElement root, @NotNull Document document, boolean quick) {
    List<FoldingDescriptor> descriptors = new ArrayList<>();

    PsiTreeUtil.processElements(root, element -> {
        IElementType elementType = element.getNode().getElementType();
        MlTypes types = elementType.getLanguage() == RmlLanguage.INSTANCE ? RmlTypes.INSTANCE : OclTypes.INSTANCE;
        if (types.COMMENT == elementType) {
            FoldingDescriptor fold = fold(element);
            if (fold != null) {
                descriptors.add(fold);
            }
        } else if (types.TYPE_EXPRESSION == elementType) {
            foldType(descriptors, (PsiType) element);
        } else if (types.LET_EXPRESSION == elementType) {
            foldLet(descriptors, (PsiLet) element);
        } else if (types.MODULE_EXPRESSION == elementType) {
            foldModule(descriptors, (PsiModule) element);
        }
        return true;
    });

    return descriptors.toArray(new FoldingDescriptor[descriptors.size()]);
}
 
开发者ID:reasonml-editor,项目名称:reasonml-idea-plugin,代码行数:26,代码来源:FoldingBuilder.java

示例2: buildFoldRegions

import com.intellij.lang.folding.FoldingDescriptor; //导入依赖的package包/类
@NotNull
@Override
public FoldingDescriptor[] buildFoldRegions(@NotNull PsiElement root, @NotNull Document document, boolean quick) {
    FoldingGroup group = FoldingGroup.newGroup("TYPO3Route");

    List<FoldingDescriptor> descriptors = new ArrayList<>();
    Collection<StringLiteralExpression> literalExpressions = PsiTreeUtil.findChildrenOfType(root, StringLiteralExpression.class);

    for (final StringLiteralExpression literalExpression : literalExpressions) {
        for (PsiReference reference : literalExpression.getReferences()) {
            if (reference instanceof RouteReference) {
                String value = literalExpression.getContents();

                FoldingDescriptor descriptor = foldRouteReferenceString(reference, value, group);
                if (descriptor != null) {
                    descriptors.add(descriptor);
                }
            }
        }


    }

    return descriptors.toArray(new FoldingDescriptor[descriptors.size()]);
}
 
开发者ID:cedricziel,项目名称:idea-php-typo3-plugin,代码行数:26,代码来源:RouteFoldingBuilder.java

示例3: buildFoldRegions

import com.intellij.lang.folding.FoldingDescriptor; //导入依赖的package包/类
@NotNull
@Override
public FoldingDescriptor[] buildFoldRegions(
    @NotNull final PsiElement root,
    @NotNull final Document document,
    final boolean quick
) {
    if (!(root instanceof BladeFileImpl)) {
        return FoldingDescriptor.EMPTY.clone();
    }

    final Queue<BladePsiDirective> directives         = new LinkedBlockingQueue(Arrays.asList(((BladeFileImpl) root).getDirectives()));
    final List<FoldingDescriptor>  foldingDescriptors = new ArrayList<>();

    processDirectives(null, directives, foldingDescriptors, document);

    return foldingDescriptors.toArray(new FoldingDescriptor[foldingDescriptors.size()]);
}
 
开发者ID:rentalhost,项目名称:laravel-insight,代码行数:19,代码来源:BladeFoldingBuilder.java

示例4: appendDescriptors

import com.intellij.lang.folding.FoldingDescriptor; //导入依赖的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();
    }
}
 
开发者ID:datathings,项目名称:greycat-idea-plugin,代码行数:26,代码来源:GCMFoldingBuilder.java

示例5: buildFoldRegions

import com.intellij.lang.folding.FoldingDescriptor; //导入依赖的package包/类
@NotNull
@Override
public FoldingDescriptor[] buildFoldRegions(@NotNull PsiElement psiElement, @NotNull Document document, boolean quick) {

  if (!psiElement.getClass().getCanonicalName()
      .equals("org.jetbrains.kotlin.psi.KtFile") || quick || !LoggerFoldingApplicationSettings.getInstance()
      .getState()
      .getCollapseByDefault()) {
    return new FoldingDescriptor[0];
  }

  List<FoldingDescriptor> foldingDescriptors = new LinkedList<>();

  Project project = psiElement.getProject();
  LoggerFoldingProjectSettings.State state = LoggerFoldingProjectSettings.getInstance(project).getState();

  buildFoldRegions(psiElement, foldingDescriptors, state);

  return foldingDescriptors.toArray(new FoldingDescriptor[foldingDescriptors.size()]);
}
 
开发者ID:healarconr,项目名称:logger-folding,代码行数:21,代码来源:KotlinFoldingBuilder.java

示例6: buildFoldRegions

import com.intellij.lang.folding.FoldingDescriptor; //导入依赖的package包/类
@NotNull
@Override
public FoldingDescriptor[] buildFoldRegions(@NotNull PsiElement psiElement, @NotNull Document document, boolean quick) {

  if (!(psiElement instanceof PsiJavaFile) || quick || !LoggerFoldingApplicationSettings.getInstance().getState()
      .getCollapseByDefault()) {
    return new FoldingDescriptor[0];
  }

  List<FoldingDescriptor> foldingDescriptors = new LinkedList<>();

  Project project = psiElement.getProject();
  LoggerFoldingProjectSettings.State state = LoggerFoldingProjectSettings.getInstance(project).getState();

  buildFoldRegions(psiElement, foldingDescriptors, state);

  return foldingDescriptors.toArray(new FoldingDescriptor[foldingDescriptors.size()]);
}
 
开发者ID:healarconr,项目名称:logger-folding,代码行数:19,代码来源:JavaFoldingBuilder.java

示例7: collectDescriptorsRecursively

import com.intellij.lang.folding.FoldingDescriptor; //导入依赖的package包/类
private static void collectDescriptorsRecursively(@NotNull ASTNode node,
                                                  @NotNull Document document,
                                                  @NotNull List<FoldingDescriptor> descriptors) {
    final IElementType type = node.getElementType();
    if (type == token(COMMENT)
            && spanMultipleLines(node, document)) {
        descriptors.add(new FoldingDescriptor(node, node.getTextRange()));
    }
    if (type == token(LINE_COMMENT)) {
        final Couple<PsiElement> commentRange = expandLineCommentsRange(node.getPsi());
        final int startOffset = commentRange.getFirst().getTextRange().getStartOffset();
        final int endOffset = commentRange.getSecond().getTextRange().getEndOffset();
        if (document.getLineNumber(startOffset) != document.getLineNumber(endOffset)) {
            descriptors.add(new FoldingDescriptor(node, new TextRange(startOffset, endOffset)));
        }
    }
    if (PROVIDERS.keySet().contains(type)
            && spanMultipleLines(node, document)) {
        descriptors.add(new FoldingDescriptor(node, node.getTextRange()));
    }
    for (ASTNode child : node.getChildren(null)) {
        collectDescriptorsRecursively(child, document, descriptors);
    }
}
 
开发者ID:protostuff,项目名称:protobuf-jetbrains-plugin,代码行数:25,代码来源:ProtoFoldingBuilder.java

示例8: buildFoldRegions

import com.intellij.lang.folding.FoldingDescriptor; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@NotNull
@Override
public FoldingDescriptor[] buildFoldRegions(@NotNull PsiElement root, @NotNull Document document, boolean quick) {

    Collection<? extends PsiElement> objects = PsiTreeUtil.findChildrenOfAnyType(root, IonObject.class,
            IonArray.class,
            IonExpression.class);
    if (objects.isEmpty()) {
        return new FoldingDescriptor[0];
    }

    List<FoldingDescriptor> descriptors = new ArrayList<FoldingDescriptor>();

    for (PsiElement object : objects) {
        final int startOffset = object.getTextRange().getStartOffset() + 1;
        final int endOffset = object.getTextRange().getEndOffset() - 1;
        if ((startOffset + 1) < endOffset) {
            TextRange range = new TextRange(startOffset, endOffset);
            descriptors.add(new FoldingDescriptor(object.getNode(), range));
        }
    }
    return descriptors.toArray(new FoldingDescriptor[descriptors.size()]);
}
 
开发者ID:amzn,项目名称:ion-intellij-plugin,代码行数:25,代码来源:IonFoldingBuilder.java

示例9: addAnnotationsToFold

import com.intellij.lang.folding.FoldingDescriptor; //导入依赖的package包/类
private void addAnnotationsToFold(PsiModifierList modifierList, List<FoldingDescriptor> foldElements, Document document) {
  if (modifierList == null) return;
  PsiElement[] children = modifierList.getChildren();
  for (int i = 0; i < children.length; i++) {
    PsiElement child = children[i];
    if (child instanceof PsiAnnotation) {
      addToFold(foldElements, child, document, false);
      int j;
      for (j = i + 1; j < children.length; j++) {
        PsiElement nextChild = children[j];
        if (nextChild instanceof PsiModifier) break;
      }

      //noinspection AssignmentToForLoopParameter
      i = j;
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:JavaFoldingBuilderBase.java

示例10: addMethodGenericParametersFolding

import com.intellij.lang.folding.FoldingDescriptor; //导入依赖的package包/类
private static void addMethodGenericParametersFolding(PsiMethodCallExpression expression, List<FoldingDescriptor> foldElements, Document document, boolean quick) {
  final PsiReferenceExpression methodExpression = expression.getMethodExpression();
  final PsiReferenceParameterList list = methodExpression.getParameterList();
  if (list == null || list.getTextLength() <= 5) {
    return;
  }

  PsiMethodCallExpression element = expression;
  while (true) {
    if (!quick && !resolvesCorrectly(element.getMethodExpression())) return;
    final PsiElement parent = element.getParent();
    if (!(parent instanceof PsiExpressionList) || !(parent.getParent() instanceof PsiMethodCallExpression)) break;
    element = (PsiMethodCallExpression)parent.getParent();
  }

  addTypeParametersFolding(foldElements, document, list, 3, quick);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:JavaFoldingBuilderBase.java

示例11: addTypeParametersFolding

import com.intellij.lang.folding.FoldingDescriptor; //导入依赖的package包/类
private static void addTypeParametersFolding(List<FoldingDescriptor> foldElements, Document document, PsiReferenceParameterList list,
                                      final int ifLongerThan, boolean quick) {
  if (!quick) {
    for (final PsiType type : list.getTypeArguments()) {
      if (!type.isValid()) {
        return;
      }
      if (type instanceof PsiClassType || type instanceof PsiArrayType) {
        if (PsiUtil.resolveClassInType(type) == null) {
          return;
        }
      }
    }
  }

  final String text = list.getText();
  if (text.startsWith("<") && text.endsWith(">") && text.length() > ifLongerThan) {
    final TextRange range = list.getTextRange();
    addFoldRegion(foldElements, list, document, true, range);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:JavaFoldingBuilderBase.java

示例12: buildDescriptors

import com.intellij.lang.folding.FoldingDescriptor; //导入依赖的package包/类
@NotNull
public List<FoldingDescriptor> buildDescriptors() {
  myCallArguments = getArguments(myCallExpression);

  if (myCallArguments != null && myCallArguments.length >= MIN_ARGS_TO_FOLD && hasLiteralExpression(myCallArguments)) {
    PsiMethod method = myCallExpression.resolveMethod();

    if (method != null) {
      myParameters = method.getParameterList().getParameters();
      if (myParameters.length == myCallArguments.length) {
        return buildDescriptorsForLiteralArguments();
      }
    }
  }

  return ContainerUtil.emptyList();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:ParameterNameFoldingManager.java

示例13: buildDescriptorsForLiteralArguments

import com.intellij.lang.folding.FoldingDescriptor; //导入依赖的package包/类
@NotNull
private List<FoldingDescriptor> buildDescriptorsForLiteralArguments() {
  List<FoldingDescriptor> descriptors = ContainerUtil.newArrayList();

  int i = 0;
  while (i < myCallArguments.length) {
    if (i + 1 < myCallArguments.length && isCommonlyNamedParameterPair(i, i + 1)) {
      i += 2;
      continue;
    }

    if (shouldInlineParameterName(i)) {
      descriptors.add(createFoldingDescriptor(myCallArguments[i], myParameters[i]));
    }
    i++;
  }

  return descriptors;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:ParameterNameFoldingManager.java

示例14: buildFoldRegions

import com.intellij.lang.folding.FoldingDescriptor; //导入依赖的package包/类
@NotNull
@Override
public FoldingDescriptor[] buildFoldRegions(@NotNull PsiElement root, @NotNull Document document, boolean quick) {
  if (!(root instanceof PsiJavaFile) || quick || !JavaCodeFoldingSettings.getInstance().isCollapseSuppressWarnings()) {
    return FoldingDescriptor.EMPTY;
  }
  if (!PsiUtil.isLanguageLevel5OrHigher(root)) {
    return FoldingDescriptor.EMPTY;
  }
  final List<FoldingDescriptor> result = new ArrayList<FoldingDescriptor>();
  root.accept(new JavaRecursiveElementWalkingVisitor(){
    @Override
    public void visitAnnotation(PsiAnnotation annotation) {
      if (Comparing.strEqual(annotation.getQualifiedName(), SuppressWarnings.class.getName())) {
        result.add(new FoldingDescriptor(annotation, annotation.getTextRange()));
      }
      super.visitAnnotation(annotation);
    }
  });
  return result.toArray(new FoldingDescriptor[result.size()]);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:SuppressWarningsFoldingBuilder.java

示例15: collectDescriptors

import com.intellij.lang.folding.FoldingDescriptor; //导入依赖的package包/类
private void collectDescriptors(@NotNull final ASTNode node, @NotNull final List<FoldingDescriptor> descriptors) {
  final Queue<ASTNode> toProcess = new LinkedList<ASTNode>();
  toProcess.add(node);
  while (!toProcess.isEmpty()) {
    final ASTNode current = toProcess.remove();
    if (current.getTreeParent() != null
        && current.getTextLength() > 1
        && myTokenSet.contains(current.getElementType()))
    {
      descriptors.add(new FoldingDescriptor(current, current.getTextRange()));
    }
    for (ASTNode child = current.getFirstChildNode(); child != null; child = child.getTreeNext()) {
      toProcess.add(child);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:IndentationFoldingBuilder.java


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