Java Code Examples for com.intellij.openapi.editor.FoldingGroup#newGroup()
The following examples show how to use
com.intellij.openapi.editor.FoldingGroup#newGroup() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RouteFoldingBuilder.java From idea-php-typo3-plugin with MIT License | 6 votes |
@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[0]); }
Example 2
Source File: JsonnetFoldingBuilder.java From intellij-jsonnet with Apache License 2.0 | 5 votes |
@NotNull @Override public FoldingDescriptor[] buildFoldRegions(@NotNull PsiElement root, @NotNull Document document, boolean quick) { List<FoldingDescriptor> descriptors = new ArrayList<>(); Collection<PsiElement> literalExpressions = PsiTreeUtil.findChildrenOfType(root, JsonnetObj.class); literalExpressions.addAll(PsiTreeUtil.findChildrenOfType(root, JsonnetArr.class)); literalExpressions.addAll(PsiTreeUtil.findChildrenOfType(root, JsonnetArrcomp.class)); for (final PsiElement literalExpression : literalExpressions) { FoldingGroup group = FoldingGroup.newGroup( "jsonnet-" + literalExpression.getTextRange().getStartOffset() + "-" + literalExpression.getTextRange().getEndOffset() ); int start = literalExpression.getTextRange().getStartOffset() + 1; int end = literalExpression.getTextRange().getEndOffset() - 1; if (end > start) descriptors.add( new FoldingDescriptor( literalExpression.getNode(), new TextRange(start, end), group ) { @Override public String getPlaceholderText() { return "..."; } } ); } return descriptors.toArray(new FoldingDescriptor[0]); }
Example 3
Source File: TranslationFoldingBuilder.java From idea-php-typo3-plugin with MIT License | 5 votes |
@NotNull @Override public FoldingDescriptor[] buildFoldRegions(@NotNull PsiElement root, @NotNull Document document, boolean quick) { if (!TYPO3CMSProjectSettings.isEnabled(root) || !TYPO3CMSProjectSettings.getInstance(root.getProject()).translationEnableTextFolding) { return FoldingDescriptor.EMPTY; } FoldingGroup group = FoldingGroup.newGroup("TYPO3Translation"); List<FoldingDescriptor> descriptors = new ArrayList<>(); Collection<StringLiteralExpression> literalExpressions = PsiTreeUtil.findChildrenOfType(root, StringLiteralExpression.class); for (final StringLiteralExpression literalExpression : literalExpressions) { String value = literalExpression.getContents(); if (value.startsWith("LLL:")) { final String transResult = Translator.translateLLLString(literalExpression); if (transResult != null) { TextRange foldingRange = new TextRange(literalExpression.getTextRange().getStartOffset() + 1, literalExpression.getTextRange().getEndOffset() - 1); descriptors.add(new FoldingDescriptor(literalExpression.getNode(), foldingRange, group) { @Override public String getPlaceholderText() { return transResult; } }); } } } return descriptors.toArray(new FoldingDescriptor[0]); }
Example 4
Source File: DefaultPropertyFoldingBuilder.java From litho with Apache License 2.0 | 4 votes |
@NotNull @Override public FoldingDescriptor[] buildFoldRegions( @NotNull PsiElement root, @NotNull Document document, boolean quick) { FoldingGroup group = FoldingGroup.newGroup(FOLDING_GROUP_NAME); final Map<String, PsiExpression> defaultProps = PsiTreeUtil.findChildrenOfType(root, PsiField.class).stream() .filter(LithoPluginUtils::isPropDefault) .filter(field -> field.getInitializer() != null) .collect(Collectors.toMap(PsiField::getName, PsiField::getInitializer)); if (defaultProps.isEmpty()) { return FoldingDescriptor.EMPTY; } return PsiTreeUtil.findChildrenOfType(root, PsiParameter.class).stream() .filter(LithoPluginUtils::isProp) .map( parameter -> { String name = parameter.getName(); if (name == null) { return null; } PsiExpression nameExpression = defaultProps.get(name); if (nameExpression == null) { return null; } PsiIdentifier nameIdentifier = parameter.getNameIdentifier(); if (nameIdentifier == null) { return null; } return new FoldingDescriptor( nameIdentifier.getNode(), nameIdentifier.getTextRange(), group) { @Override public String getPlaceholderText() { return name + ": " + nameExpression.getText(); } }; }) .filter(Objects::nonNull) .toArray(FoldingDescriptor[]::new); }
Example 5
Source File: NutzLocalizationFoldingDescriptor.java From NutzCodeInsight with Apache License 2.0 | 4 votes |
public NutzLocalizationFoldingDescriptor(@NotNull ASTNode node, @NotNull TextRange range, String value) { super(node, range, FoldingGroup.newGroup("Nutz")); this.value = value; }