forked from unshare/hybris-integration-intellij-idea-plugin
-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#897 | Customized folding for
User Rights
permission flags
- Loading branch information
Showing
4 changed files
with
22 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/* | ||
* This file is part of "SAP Commerce Developers Toolset" plugin for Intellij IDEA. | ||
* Copyright (C) 2019-2023 EPAM Systems <[email protected]> and contributors | ||
* Copyright (C) 2019-2024 EPAM Systems <[email protected]> and contributors | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as | ||
|
@@ -20,6 +20,7 @@ | |
|
||
import com.intellij.idea.plugin.hybris.impex.lang.folding.util.ImpExFoldingLinesFilter; | ||
import com.intellij.idea.plugin.hybris.impex.psi.ImpexTypes; | ||
import com.intellij.idea.plugin.hybris.impex.utils.ImpexPsiUtils; | ||
import com.intellij.lang.ASTNode; | ||
import com.intellij.lang.folding.FoldingDescriptor; | ||
import com.intellij.openapi.editor.Document; | ||
|
@@ -36,8 +37,6 @@ | |
import java.util.List; | ||
import java.util.Objects; | ||
|
||
import static com.intellij.idea.plugin.hybris.impex.utils.ImpexPsiUtils.*; | ||
|
||
public class ImpexFoldingLinesBuilder extends AbstractImpExFoldingBuilder { | ||
|
||
private static final String LINE_GROUP_NAME = "impex_fold_line"; | ||
|
@@ -64,16 +63,16 @@ public FoldingDescriptor[] buildFoldRegionsInternal( | |
final int nextIdx = Math.min(i + 1, size - 1); | ||
|
||
final PsiElement element = foldingBlocks.get(i); | ||
if (isHeaderLine(element) || isUserRightsMacros(element)) { | ||
if (ImpexPsiUtils.isHeaderLine(element) || ImpexPsiUtils.isUserRightsMacros(element)) { | ||
startGroupElement = foldingBlocks.get(nextIdx); | ||
if (groupIsNotFresh) { | ||
currentLineGroup = FoldingGroup.newGroup(LINE_GROUP_NAME); | ||
countLinesOnGroup = 0; | ||
groupIsNotFresh = false; | ||
} | ||
} else { | ||
if (nextElementIsHeaderLine(element) | ||
|| nextElementIsUserRightsMacros(element) | ||
if (ImpexPsiUtils.nextElementIsHeaderLine(element) | ||
|| ImpexPsiUtils.nextElementIsUserRightsMacros(element) | ||
|| nextIdx == size) { | ||
if (countLinesOnGroup > 1) { | ||
descriptors.add(new ImpexFoldingDescriptor( | ||
|
@@ -82,8 +81,8 @@ public FoldingDescriptor[] buildFoldRegionsInternal( | |
element.getTextRange().getEndOffset(), | ||
currentLineGroup, | ||
(elm) -> { | ||
final PsiElement prevSibling = getPrevNonWhitespaceElement(elm); | ||
if ((isHeaderLine(prevSibling) || isUserRightsMacros(prevSibling))) { | ||
final PsiElement prevSibling = ImpexPsiUtils.getPrevNonWhitespaceElement(elm); | ||
if ((ImpexPsiUtils.isHeaderLine(prevSibling) || ImpexPsiUtils.isUserRightsMacros(prevSibling))) { | ||
return ";....;...."; | ||
} | ||
return ""; | ||
|
@@ -93,7 +92,7 @@ public FoldingDescriptor[] buildFoldRegionsInternal( | |
groupIsNotFresh = true; | ||
} | ||
} | ||
if (isImpexValueLine(element)) { | ||
if (ImpexPsiUtils.isImpexValueLine(element)) { | ||
countLinesOnGroup++; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/* | ||
* This file is part of "SAP Commerce Developers Toolset" plugin for Intellij IDEA. | ||
* Copyright (C) 2014-2016 Alexander Bartash <[email protected]> | ||
* Copyright (C) 2019-2023 EPAM Systems <[email protected]> and contributors | ||
* Copyright (C) 2019-2024 EPAM Systems <[email protected]> and contributors | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as | ||
|
@@ -20,6 +20,7 @@ package com.intellij.idea.plugin.hybris.impex.lang.folding.util | |
|
||
import com.intellij.idea.plugin.hybris.impex.psi.ImpexAttribute | ||
import com.intellij.idea.plugin.hybris.impex.psi.ImpexParameters | ||
import com.intellij.idea.plugin.hybris.impex.psi.ImpexUserRightsPermissionValue | ||
import com.intellij.idea.plugin.hybris.impex.utils.ImpexPsiUtils | ||
import com.intellij.openapi.components.Service | ||
import com.intellij.psi.PsiElement | ||
|
@@ -32,6 +33,7 @@ class ImpExSmartFoldingBlocksFilter : AbstractImpExFoldingFilter() { | |
|
||
private fun isSupportedType(element: PsiElement) = element is ImpexAttribute | ||
|| element is ImpexParameters | ||
|| element is ImpexUserRightsPermissionValue | ||
|| ImpexPsiUtils.isLineBreak(element) | ||
|
||
private fun isNotBlankPlaceholder(element: PsiElement) = ImpExSmartFoldingPlaceholderBuilder.getInstance().getPlaceholder(element) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters