Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove usages of getPsi() #2901

Open
wants to merge 74 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
7f8984c
implement ASTNode.isPartOfComment without psi
mgroth0 Dec 8, 2024
2562354
remove psi from existingSuppressionsFromNamedArgumentOrNull
mgroth0 Dec 10, 2024
a05595f
remove psi from visitKtlintSuppressionInAnnotation
mgroth0 Dec 10, 2024
1b76046
remove psi from getAnnotationUseSiteTarget
mgroth0 Dec 10, 2024
546dfca
remove psi from isOnSameLineAsControlFlowKeyword
mgroth0 Dec 10, 2024
5f0f4a8
reduce psi in NoUnusedImportsRule
mgroth0 Dec 10, 2024
7e2f282
remove psi from SpacingAroundColonRule
mgroth0 Dec 10, 2024
bd1596b
remove psi from SpacingAroundDoubleColonRule
mgroth0 Dec 10, 2024
d0c798e
remove psi from StatementWrappingRule
mgroth0 Dec 10, 2024
0058330
reduce psi in TrailingCommaOnDeclarationSiteRule
mgroth0 Dec 10, 2024
a10fd38
deprecate and replace usages of "isPartOf(klass: KClass<out PsiElemen…
mgroth0 Dec 10, 2024
94624ba
remove psi from SuppressionLocator
mgroth0 Dec 10, 2024
e962b64
simple psi removals
mgroth0 Dec 10, 2024
c8d1a54
refactor token sets
mgroth0 Dec 10, 2024
efd32be
remove psi from BlankLineBeforeDeclarationRule
mgroth0 Dec 10, 2024
6094819
remove psi from EnumEntryNameCaseRule
mgroth0 Dec 10, 2024
e2846c1
changs from review
mgroth0 Dec 20, 2024
fe71a48
add kdoc for findChildByTypeRecursively and endOffset
mgroth0 Dec 29, 2024
d92140d
remove a getPsi() from TrailingCommaOnDeclarationSiteRule
mgroth0 Dec 29, 2024
ffda19b
add contract to isWhiteSpace
mgroth0 Dec 29, 2024
3efbf7a
make token sets more maintainable
mgroth0 Dec 29, 2024
cb757a9
alternative solution to token set
mgroth0 Dec 29, 2024
4574a59
Refactor - use less Psi functions
paul-dingemans Dec 30, 2024
bcc14a6
Generify alternative solution to token set
paul-dingemans Jan 1, 2025
2c7c9e8
Respect max line length in kdoc
paul-dingemans Jan 1, 2025
72fb3c0
clean up alternative psi-type-checking strategy and remove getPsi() c…
mgroth0 Jan 1, 2025
2ecce76
Create dummy KtFile with PsiFileFactory analog to KotlinPsiFileFactory
paul-dingemans Jan 2, 2025
729425e
make isDeclaration() match previous behavior
mgroth0 Jan 6, 2025
0a8ab03
make isDeclaration public and use it in all rules
mgroth0 Jan 6, 2025
d6a5985
consider PROPERTY_ACCESSOR a declaration to match previous behavior
mgroth0 Jan 6, 2025
1ac41d3
make SpacingBetweenDeclarationsWithCommentsRule work correctly when t…
mgroth0 Jan 6, 2025
61eec00
fix(deps): update dependency io.github.hakky54:logcaptor to v2.10.1 (…
renovate[bot] Jan 12, 2025
7c7ce03
fix(deps): update dependency org.assertj:assertj-core to v3.27.3 (#2927)
renovate[bot] Jan 19, 2025
3b3de8c
chore(deps): update plugin com.gradle.develocity to v3.19.1 (#2929)
renovate[bot] Jan 27, 2025
3bdcc25
chore(deps): update dependency gradle to v8.12.1 (#2930)
renovate[bot] Jan 27, 2025
2f96c19
fix(deps): update kotlin monorepo to v2.1.10 (#2931)
renovate[bot] Jan 27, 2025
de2cb2d
fix(deps): update dependency org.jetbrains.kotlin:kotlin-gradle-plugi…
renovate[bot] Feb 3, 2025
cc7b874
chore(deps): update plugin shadow to v8.3.6 (#2935)
renovate[bot] Feb 3, 2025
1692979
Fix incorrect error message in PropertyNamingRule when enforcing Pasc…
lsurvila Feb 3, 2025
c160383
fix(deps): update dependency io.github.oshai:kotlin-logging-jvm to v7…
renovate[bot] Feb 8, 2025
61ac7b8
implement ASTNode.isPartOfComment without psi
mgroth0 Dec 8, 2024
0d361af
remove psi from existingSuppressionsFromNamedArgumentOrNull
mgroth0 Dec 10, 2024
354dcac
remove psi from visitKtlintSuppressionInAnnotation
mgroth0 Dec 10, 2024
3e30bdc
remove psi from getAnnotationUseSiteTarget
mgroth0 Dec 10, 2024
cb90a91
remove psi from isOnSameLineAsControlFlowKeyword
mgroth0 Dec 10, 2024
85d827f
reduce psi in NoUnusedImportsRule
mgroth0 Dec 10, 2024
8b43e13
remove psi from SpacingAroundColonRule
mgroth0 Dec 10, 2024
b1ec1e5
remove psi from SpacingAroundDoubleColonRule
mgroth0 Dec 10, 2024
deadf90
remove psi from StatementWrappingRule
mgroth0 Dec 10, 2024
e0b1e27
reduce psi in TrailingCommaOnDeclarationSiteRule
mgroth0 Dec 10, 2024
b8410a3
deprecate and replace usages of "isPartOf(klass: KClass<out PsiElemen…
mgroth0 Dec 10, 2024
036a957
remove psi from SuppressionLocator
mgroth0 Dec 10, 2024
8904017
simple psi removals
mgroth0 Dec 10, 2024
a48b0a3
refactor token sets
mgroth0 Dec 10, 2024
4fab5ee
remove psi from BlankLineBeforeDeclarationRule
mgroth0 Dec 10, 2024
911330c
remove psi from EnumEntryNameCaseRule
mgroth0 Dec 10, 2024
2e7bf04
changs from review
mgroth0 Dec 20, 2024
a34bd56
add kdoc for findChildByTypeRecursively and endOffset
mgroth0 Dec 29, 2024
b082814
remove a getPsi() from TrailingCommaOnDeclarationSiteRule
mgroth0 Dec 29, 2024
b0f79f7
add contract to isWhiteSpace
mgroth0 Dec 29, 2024
58acdb5
make token sets more maintainable
mgroth0 Dec 29, 2024
08d648f
alternative solution to token set
mgroth0 Dec 29, 2024
cfbe206
Refactor - use less Psi functions
paul-dingemans Dec 30, 2024
a48e45d
Generify alternative solution to token set
paul-dingemans Jan 1, 2025
c525dda
Respect max line length in kdoc
paul-dingemans Jan 1, 2025
db23bcc
clean up alternative psi-type-checking strategy and remove getPsi() c…
mgroth0 Jan 1, 2025
6e2d805
Create dummy KtFile with PsiFileFactory analog to KotlinPsiFileFactory
paul-dingemans Jan 2, 2025
e0f9d82
make isDeclaration() match previous behavior
mgroth0 Jan 6, 2025
631e2fc
make isDeclaration public and use it in all rules
mgroth0 Jan 6, 2025
564268e
consider PROPERTY_ACCESSOR a declaration to match previous behavior
mgroth0 Jan 6, 2025
31b598c
make SpacingBetweenDeclarationsWithCommentsRule work correctly when t…
mgroth0 Jan 6, 2025
90487fc
Create dummy KtFile with PsiFileFactory analog to KotlinPsiFileFactory
paul-dingemans Feb 9, 2025
00a4664
Refactor for readability
paul-dingemans Feb 9, 2025
40d2918
Merge remote-tracking branch 'github-desktop-mgroth0/no-psi' into pr/…
paul-dingemans Feb 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import com.pinterest.ktlint.rule.engine.core.api.ElementType.VARARG_KEYWORD
import com.pinterest.ktlint.rule.engine.core.api.ElementType.VAR_KEYWORD
import com.pinterest.ktlint.rule.engine.core.api.ElementType.WHITE_SPACE
import org.jetbrains.kotlin.com.intellij.lang.ASTNode
import org.jetbrains.kotlin.com.intellij.psi.PsiComment
import org.jetbrains.kotlin.com.intellij.psi.PsiElement
import org.jetbrains.kotlin.com.intellij.psi.impl.source.tree.CompositeElement
import org.jetbrains.kotlin.com.intellij.psi.impl.source.tree.LeafElement
Expand Down Expand Up @@ -223,7 +222,11 @@ public fun ASTNode.isLeaf(): Boolean = firstChildNode == null
*/
public fun ASTNode.isCodeLeaf(): Boolean = isLeaf() && !isWhiteSpace() && !isPartOfComment()

public fun ASTNode.isPartOfComment(): Boolean = parent(strict = false) { it.psi is PsiComment } != null
public fun ASTNode.isPartOfComment(): Boolean =
parent(strict = false) {
val eType = it.elementType
eType == ElementType.BLOCK_COMMENT || eType == ElementType.EOL_COMMENT || eType == ElementType.KDOC
} != null

public fun ASTNode.children(): Sequence<ASTNode> = generateSequence(firstChildNode) { node -> node.treeNext }

Expand Down